[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

Henry Wong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 22 05:09:02 PDT 2018


MTC added inline comments.
Herald added subscribers: dkrupp, rnkovacs.
Herald added a reviewer: george.karpenkov.


================
Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:107
+                                          equalsBoundNode("initVarName"))))),
+                                      hasRHS(integerLiteral())))),
+             // Incrementation should be a simple increment or decrement
----------------
Hi Peter, sorry to bother you! 

I have some confusion here. Whether `hasRHS(integerLiteral())` needs to added with `ignoringParenImpCasts`? 

The given code below does not unroll the loop because `i = 0;` has a `ImplicitCastExpr` for `0`. But if I change `unsigned i = 0` to `int i = 0`, loop unrolling will happen. So I don't know if this is intentional. 
```
int func() {
  int sum = 0;
  unsigned i;
  for (i = 0; i < 10; ++i) {
    sum++;
  }
  return sum;
}
```

Hope you can help me, thank you!


https://reviews.llvm.org/D34260





More information about the cfe-commits mailing list