[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2022-01-15 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. Herald added a subscriber: carlosgalvezp. Sorry its been so long, How does this handle cases where the variable contains resources. Like a vector being used in a loop where you don't want to release its memory between each iteration. void foo(){ std::vector

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-05-24 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 added a comment. Dear reviewers, Since this work was conducted as part of a bachelor's thesis, which has to be handed in on the 18th of June 2021, we wanted to add a friendly ping to this patch. It would make us, the thesis team, proud to state that some of our work was accepted and

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-30 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 updated this revision to Diff 341929. DNS320 added a comment. Removed a link to the ES.26 C++ Core Guideline in the documentation part. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100092/new/ https://reviews.llvm.org/D100092 Files:

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-30 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 marked an inline comment as done. DNS320 added a comment. In D100092#2726808 , @steveire wrote: > I implemented something like this recently too. The code I was trying to > refactor was something like > > auto ii = 0; > for (ii = 0; ii <

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-30 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 updated this revision to Diff 341784. DNS320 added a comment. Renamed the IsInsideMatchedForStmt() function according to a comment from the build system. Changed a data type to "auto" according to a comment from Eugene.Zelenko. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment. I implemented something like this recently too. The code I was trying to refactor was something like auto ii = 0; for (ii = 0; ii < thing.size(); ++ii) { // code } // code for (ii = 0; ii < thing.size(); ++ii) { // code } // code for (ii

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp:37 + bool VisitDeclRefExpr(DeclRefExpr *D) { +if (const VarDecl *To = dyn_cast(D->getDecl())) { + if (To == MatchedDecl &&

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-29 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp:28 + + diag(MatchedForStmt->getBeginLoc(), + "Prefer to declare a loop variable in the initializer part of a "

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-29 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 updated this revision to Diff 341492. DNS320 marked 7 inline comments as done. DNS320 added a comment. I updated the check according to the last review. The check should now fully implement the defined enforcement chapter from the ES.74 C++ Core Guideline. About searching for declRefExpr

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-09 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 added a comment. Thank you for your reviews. I will work on your comments and write back soon. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100092/new/ https://reviews.llvm.org/D100092 ___

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. I'd argue this check isn't following the enforcement specified in the relevant guideline: Enforcement: Warn when a variable modified inside the for-statement is declared outside the loop and not being used outside the loop. All this is checking is that there is a

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp:28 + + diag(MatchedForStmt->getBeginLoc(), + "Prefer to declare a loop variable in the initializer part of a "

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-08 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 created this revision. DNS320 added reviewers: aaron.ballman, njames93, alexfh. DNS320 added a project: clang-tools-extra. Herald added subscribers: shchenz, kbarton, xazax.hun, mgorny, nemanjai. DNS320 requested review of this revision. This check implements the ES.74