[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 13 04:44:48 PST 2026


================
@@ -1996,9 +1996,33 @@ namespace {
     }
 
     void VisitDeclRefExpr(DeclRefExpr *E) {
-      if (VarDecl *VD = dyn_cast<VarDecl>(E->getDecl()))
+      if (VarDecl *VD = dyn_cast<VarDecl>(E->getDecl())) {
         if (Decls.count(VD))
           FoundDecl = true;
+      } else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(E->getDecl());
----------------
AaronBallman wrote:

```suggestion
      } else if (const auto *MD = dyn_cast<CXXMethodDecl>(E->getDecl());
```

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


More information about the cfe-commits mailing list