[PATCH] D41815: [clang-tidy] implement check for goto

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 11 04:53:40 PST 2018


JonasToth updated this revision to Diff 129433.
JonasToth added a comment.

I enhanced the check to do more:

- check that jumps will only be forward. AFAIK that is required in all sensefull usecases of goto, is it?
- additionally check for gotos in nested loops. These are not diagnosed if the jump is forward implementing the exception in the core guidelines.

With these modifications the check can be used to enforce the rule in the 
CoreGuidelines and the goto part of `6.3.1 Ensure that the label(s) for a jump statement or a switch condition appear later, in the same or an enclosing block`
for the HICPP module.

Some test cases for all combinations are missing, i can add those once you 
agree that the functionality change is indeed ok.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815

Files:
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-avoid-goto.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41815.129433.patch
Type: text/x-patch
Size: 9338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180111/b6601590/attachment.bin>


More information about the cfe-commits mailing list