[PATCH] D98338: [clang-tidy] Fix bugprone-terminating-continue when continue appears inside a switch
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 10 05:31:00 PST 2021
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Fixes https://llvm.org/PR9492.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98338
Files:
clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-terminating-continue.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-terminating-continue.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-terminating-continue.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-terminating-continue.cpp
@@ -62,4 +62,12 @@
if (n>2) continue;
}
} while (false);
+
+ do {
+ switch (2) {
+ case 1:
+ case 2:
+ continue;
+ }
+ } while (false);
}
Index: clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
@@ -26,10 +26,11 @@
equalsBoundNode("closestLoop"));
Finder->addMatcher(
- continueStmt(hasAncestor(stmt(anyOf(forStmt(), whileStmt(),
- cxxForRangeStmt(), doStmt()))
- .bind("closestLoop")),
- hasAncestor(DoWithFalse))
+ continueStmt(
+ hasAncestor(stmt(anyOf(forStmt(), whileStmt(), cxxForRangeStmt(),
+ doStmt(), switchStmt()))
+ .bind("closestLoop")),
+ hasAncestor(DoWithFalse))
.bind("continue"),
this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98338.329625.patch
Type: text/x-patch
Size: 1399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210310/f69c1f99/attachment.bin>
More information about the cfe-commits
mailing list