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

Fabian Thurnheer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 8 01:03:11 PDT 2021


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 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-for-init> rule of the C++ Core Guidelines.

The goal of this check is to find for-statements which do not declare their loop variable in the initializer part.
This limits the loop variables visibility to the scope of the loop and prevents using the loop variable for other purposes after the loop.

Thank you for the review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100092

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100092.336020.patch
Type: text/x-patch
Size: 9322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210408/29438cf5/attachment-0001.bin>


More information about the cfe-commits mailing list