[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-31 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment. Thank you for the feedback and the revert! Distinguishing condition variables from other unused variables in Wunused warnings was something I was trying initially, and I agree that it's the best way forward. The difficulty is in how to know whether an unused

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D152495#4631829 , @nickdesaulniers wrote: > Here's a more blatant regression caused by this patch. > > https://godbolt.org/z/q19Ge64G3 > > Causing breakage for the Linux kernel: >

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. Here's a more blatant regression caused by this patch. https://godbolt.org/z/q19Ge64G3 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Pranav Kant via Phabricator via cfe-commits
pranavk added a comment. I agree -Wunused-condition-variable sounds like a good idea. There are still numerous instances of this warning/error showing up when doing a self-build of LLVM, let alone warnings/errors that are showing up in internal code bases who are using LLVM HEAD for compiling

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. In D152495#4628903 , @smeenai wrote: > In D152495#4628877 , @hans wrote: > >> In D152495#4628870 , @goncharov >> wrote: >> >>> due to this

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment. In D152495#4628887 , @aaron.ballman wrote: > That might not be a bad idea in this case -- perhaps > `-Wunused-condition-variable` and group it under `-Wunused-variable`? Sounds god to me conceptually. (I don't know the code, so

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment. In D152495#4628877 , @hans wrote: > In D152495#4628870 , @goncharov > wrote: > >> due to this change we have a enourmous number of new warnings, on the other >> hand -Wunused-variable

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D152495#4628877 , @hans wrote: > In D152495#4628785 , @cor3ntin > wrote: > >> It is used, but only in an assert. Seems like the right fix! > > I suppose it is technically, but

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment. In D152495#4628785 , @cor3ntin wrote: > It is used, but only in an assert. Seems like the right fix! I suppose it is technically, but I'm not sure the fix reads like an improvement to me... I guess that's often the case with

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Mikhail Goncharov via Phabricator via cfe-commits
goncharov added a comment. due to this change we have a enourmous number of new warnings, on the other hand -Wunused-variable is a valuable warning. I am not sure what is the policy and best practices for warnings but maybe there is a possiblity to make a transition period for enabling this

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. It is used, but only in an assert. Seems like the right fix! In D152495#4628778 , @smeenai wrote: > In D152495#4628028 , @goncharov > wrote: > >> there is a number of unused vaiables

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment. In D152495#4628028 , @goncharov wrote: > there is a number of unused vaiables in conditional loops that are firing > now, I have submitted > https://github.com/llvm/llvm-project/commit/74f4daef0412be33002bd4e24a30cb47d0187ecf

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-30 Thread Mikhail Goncharov via Phabricator via cfe-commits
goncharov added a comment. there is a number of unused vaiables in conditional loops there are firing now, I have submitted https://github.com/llvm/llvm-project/commit/74f4daef0412be33002bd4e24a30cb47d0187ecf but I suspect it's just a start. How did you checked the project code for that?

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-29 Thread Takuya Shimizu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG92023b150990: Reland [Clang][SemaCXX] Add unused warning for variables declared in condition… (authored by hazohelet). Changed prior to commit: https://reviews.llvm.org/D152495?vs=550443=554539#toc

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 550443. hazohelet added a comment. Removed warning fixes that are now in D158016 CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495 Files: clang/docs/ReleaseNotes.rst

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment. Please split the warning fixes off into a separate patch. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 550433. hazohelet added a comment. Herald added subscribers: llvm-commits, wangpc, hoy, wlei, steakhal, abrachet, ormris, martong, MaskRay, hiraditya. Herald added a reviewer: NoQ. Herald added projects: LLVM, lld-macho. Herald added a reviewer: lld-macho.

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment. In D152495#4587804 , @chapuni wrote: > Would this cause many warnings in Clang/LLVM tree? > https://lab.llvm.org/buildbot/#/builders/36/builds/36560 > > I hope you to fix possible warnings at first. Thanks. I'll revert this

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment. Would this cause many warnings in Clang/LLVM tree? https://lab.llvm.org/buildbot/#/builders/36/builds/36560 I hope you to fix possible warnings at first. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-08 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment. In D152495#4566634 , @aaron.ballman wrote: > In D152495#4563520 , @hazohelet > wrote: > >> I reverted this change because it broke sanitizer buildbots. >>

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D152495#4563520 , @hazohelet wrote: > I reverted this change because it broke sanitizer buildbots. > https://lab.llvm.org/buildbot/#/builders/19/builds/18369 > The cause of the errors here are relatively clear and I can

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment. The fuzzer timeouts fail all the time; I usually just assume it's unrelated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495 ___

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-06 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment. I reverted this change because it broke sanitizer buildbots. https://lab.llvm.org/buildbot/#/builders/19/builds/18369 The cause of the errors here are relatively clear and I can speculatively replace `if (std::error_code EC = makeCanonical(Path))` with `if

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-06 Thread Takuya Shimizu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGbd0ed0abc31f: [Clang][SemaCXX] Add unused warning for variables declared in condition… (authored by hazohelet). Changed prior to commit:

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision. cor3ntin added a comment. This revision is now accepted and ready to land. LGTM, thanks. Make sure you rebase the changes to the release notes CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment. @cor3ntin It's next week :) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-14 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + // that are not referenced later. e.g.: if (int var = init()); + if (!T->isAggregateType()) +

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. This looks reasonable to me now. I'll wait next week before approving it so other get a chance to look at it :) Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + //

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-14 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + // that are not referenced later. e.g.: if (int var = init()); + if (!T->isAggregateType()) +

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-14 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 540479. hazohelet marked 6 inline comments as done. hazohelet added a comment. Address comments from Aaron and Corentin - Call `ConditionVar->setReferenced(false)` without any checks - Added some more tests CHANGES SINCE LAST ACTION

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + // that are not referenced later. e.g.: if (int var = init()); + if (!T->isAggregateType()) +

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-13 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet marked an inline comment as done. hazohelet added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + // that are not referenced later. e.g.: if (int var = init()); + if

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + // that are not referenced later. e.g.: if (int var = init()); + if (!T->isAggregateType()) +

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4016-4019 + // Ensure that `-Wunused-variable` will be emitted for condition variables + // that are not referenced later. e.g.: if (int var = init()); + if (!T->isAggregateType()) +

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 538591. hazohelet marked 5 inline comments as done. hazohelet added a comment. - Stop marking condition variable declarations as unused and diagnose all `VarDecl` that is marked used but not referenced - Added test not to warn when the declaration is not

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment. In D152495#4481588 , @aaron.ballman wrote: > This is a bit of an odd situation -- the condition variable *is* used (e.g., > its value is loaded to determine whether to go into the if branch or the else > branch), so we

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. This is a bit of an odd situation -- the condition variable *is* used (e.g., its value is loaded to determine whether to go into the if branch or the else branch), so we should not be marking it as unused in `Sema::CheckConditionVariable()`. Instead, I think we

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-06 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4003-4004 + // that are not referenced or used later. e.g.: if (int var = init()); + ConditionVar->setReferenced(false); + ConditionVar->setIsUsed(false); + tbaeder wrote: > shafik

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4003-4004 + // that are not referenced or used later. e.g.: if (int var = init()); + ConditionVar->setReferenced(false); + ConditionVar->setIsUsed(false); + shafik wrote: > That seem a

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments. Comment at: clang/lib/Sema/SemaExprCXX.cpp:4003-4004 + // that are not referenced or used later. e.g.: if (int var = init()); + ConditionVar->setReferenced(false); + ConditionVar->setIsUsed(false); + Repository: rG LLVM

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-19 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152495/new/ https://reviews.llvm.org/D152495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments. Comment at: clang/lib/CodeGen/CGExpr.cpp:2852 - "Should not use decl without marking it used!"); - if (ND->hasAttr()) { Question for other reviewers: If we want to keep this assertion, would it instead make sense to

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-08 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision. hazohelet added reviewers: aaron.ballman, tbaeder, shafik. Herald added a project: All. hazohelet requested review of this revision. Herald added a project: clang. This patch marks the declarations with initializations in condition expressions such as `if (int