[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check
Eugene Zelenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 8 07:16:54 PDT 2021
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 "
----------------
It'll be reasonable to add add note with actual variable declaration.
================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp:30
+ "Prefer to declare a loop variable in the initializer part of a "
+ "for-statement");
+}
----------------
I think should be `for statement`.
================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.h:1
+//===--- DeclareLoopVariableInTheInitializerCheck.h - clang-tidy *- C++ -*-===//
+//
----------------
I may be mistaken, but proper code is `-*- C++ -*-`. Please remove dash at left side.
================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.h:24
+class DeclareLoopVariableInTheInitializerCheck : public ClangTidyCheck {
+public:
+ DeclareLoopVariableInTheInitializerCheck(StringRef Name,
----------------
Please add `isLanguageVersionSupported`. Older versions of C doesn't support variable declarations inside `for` loops.
================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:95
+
+ Checks if a loop variable is declared in the initializer part of a for-statement.
+
----------------
I think should be for statement and for highlighted with double back-ticks.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst:6
+
+Checks if a loop variable is declared in the initializer part of a for-statement.
+
----------------
Please synchronize with statement in Release Notes.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst:8
+
+This check implements the rule `ES.74 <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es74-prefer-to-declare-a-loop-variable-in-the-initializer-part-of-a-for-statement>`_ of the C++ Core Guidelines.
+
----------------
Such references are usually placed at the end. See other checks documentation as example.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100092/new/
https://reviews.llvm.org/D100092
More information about the cfe-commits
mailing list