[clang] [analyzer] Unroll loops of compile-time upper-bounded loops (PR #169400)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 25 03:10:16 PST 2025


================
@@ -84,15 +84,17 @@ ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State) {
 
 static internal::Matcher<Stmt> simpleCondition(StringRef BindName,
                                                StringRef RefName) {
+  auto LoopVariable = ignoringParenImpCasts(
+      declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName)))
+          .bind(RefName));
+  auto UpperBound = ignoringParenImpCasts(expr().bind("boundNum"));
----------------
steakhal wrote:

Indeed might worth being explicit about this. Right now it's implicitly checked part of `EvaluateAsInt` later.
Quote:
```
  assert(!E->isValueDependent());
  if (!E->getType()->isIntegralOrEnumerationType())
    return false;
```

(Note that CSA only cares about non-dependent contexts, so that assert is harmless for us)

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


More information about the cfe-commits mailing list