[cfe-dev] [analyzer] LoopUnrolling.cpp: when the type of counter is `unsigned`, the loop does not unroll.

Henry Wong via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 22 20:42:09 PDT 2018


Hi all,

I have some confusion about LoopUnrolling.cpp.

For the code given below, the loop does not unroll because the counter is unsigned. I read the code of LoopUnrolling.cpp and I think the relevant function is `forLoopMatcher()`, see https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Core/LoopUnrolling.cpp#L152.
[https://avatars2.githubusercontent.com/u/1386314?s=400&v=4]<https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Core/LoopUnrolling.cpp#L152>

llvm-mirror/clang<https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Core/LoopUnrolling.cpp#L152>
Mirror of official clang git repository located at http://llvm.org/git/clang. Updated every five minutes.
github.com


```
int func() {
  int sum = 0;
  unsigned i;
  for (i = 0; i < 10; ++i) {
    sum++;
  }
  return sum;
}
```

1.I want to known if loop-unrolling only considers the counter of type signed?
2.Since the `IntegerLiteral` is of signed type,  when matching `IntegerLiteral`, does it need to add `ignoringParenImpCasts` to match the unsigned counter?

Henry Wong
Qihoo 360 Codesafe Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180323/abeca972/attachment.html>


More information about the cfe-dev mailing list