This revision was automatically updated to reflect the committed changes. Closed by commit rG4dd92d61dbc4: [clang-tidy] Fix bugprone-terminating-continue when continue appears inside a… (authored by njames93).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98338/new/ 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 @@ -32,6 +32,15 @@ // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue] // CHECK-FIXES: if (x > 0) break; } while (false); + + switch (2) { + case 2: + do { + continue; // LoopInSwitch + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue] + // CHECK-FIXES: break; // LoopInSwitch + } while (0); + } } void g() { @@ -62,4 +71,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); }
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 @@ -32,6 +32,15 @@ // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue] // CHECK-FIXES: if (x > 0) break; } while (false); + + switch (2) { + case 2: + do { + continue; // LoopInSwitch + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue] + // CHECK-FIXES: break; // LoopInSwitch + } while (0); + } } void g() { @@ -62,4 +71,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); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits