[clang] ccb6b0d - [clang][NFC] Move Diags.isIgnored check later in checkForRedundantLoop (#141470)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 30 08:26:33 PDT 2025
Author: Timm Baeder
Date: 2025-05-30T17:26:30+02:00
New Revision: ccb6b0dafda22360edea8dbf515f78db3c31e807
URL: https://github.com/llvm/llvm-project/commit/ccb6b0dafda22360edea8dbf515f78db3c31e807
DIFF: https://github.com/llvm/llvm-project/commit/ccb6b0dafda22360edea8dbf515f78db3c31e807.diff
LOG: [clang][NFC] Move Diags.isIgnored check later in checkForRedundantLoop (#141470)
... Iteration.
The `isIgnored()` check is more expensive than the earlier checks, so
move it last.
Added:
Modified:
clang/lib/Sema/SemaStmt.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index bc873937f6dc5..50f5757dff5bc 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2215,16 +2215,16 @@ namespace {
// Return when there is nothing to check.
if (!Body || !Third) return;
- if (S.Diags.isIgnored(diag::warn_redundant_loop_iteration,
- Third->getBeginLoc()))
- return;
-
// Get the last statement from the loop body.
CompoundStmt *CS = dyn_cast<CompoundStmt>(Body);
if (!CS || CS->body_empty()) return;
Stmt *LastStmt = CS->body_back();
if (!LastStmt) return;
+ if (S.Diags.isIgnored(diag::warn_redundant_loop_iteration,
+ Third->getBeginLoc()))
+ return;
+
bool LoopIncrement, LastIncrement;
DeclRefExpr *LoopDRE, *LastDRE;
More information about the cfe-commits
mailing list