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

Péter Szécsi via cfe-dev cfe-dev at lists.llvm.org
Wed Mar 28 12:17:30 PDT 2018


Hi Henry,

I have probably missed this mail earlier, sorry for the late answer.
1. The intention is to match as much "safe" cases as possible, and it
*should* work for unsigned as well.
2. I guess this would solve it but not sure, however, I can check this
tomorrow. (Or if you have a solution (if this works) feel free to send a
patch about it, it would help a lot :) )

Cheers,
Peter

2018-03-23 4:42 GMT+01:00 Henry Wong via cfe-dev <cfe-dev at lists.llvm.org>:

> 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://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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180328/630b0bbd/attachment.html>


More information about the cfe-dev mailing list