[clang-tools-extra] [clang-tidy] Improve `bugprone-infinite-loop` check by adding handing for structured bindings (PR #144213)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 14 03:15:12 PDT 2025


================
@@ -215,10 +236,18 @@ static bool overlap(ArrayRef<CallGraphNode *> SCC,
 
 /// returns true iff `Cond` involves at least one static local variable.
 static bool hasStaticLocalVariable(const Stmt *Cond) {
-  if (const auto *DRE = dyn_cast<DeclRefExpr>(Cond))
+  if (const auto *DRE = dyn_cast<DeclRefExpr>(Cond)) {
     if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
       if (VD->isStaticLocal())
         return true;
+
+    if (const auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
+      if (const auto *DD =
+              dyn_cast_if_present<DecompositionDecl>(BD->getDecomposedDecl()))
----------------
vbvictor wrote:

same with `dyn_cast_if_present` here

https://github.com/llvm/llvm-project/pull/144213


More information about the cfe-commits mailing list