]> granicus.if.org Git - clang/commit
[analyzer] Unroll the loop when it has a unsigned counter.
authorHenry Wong <movietravelcode@outlook.com>
Sat, 31 Mar 2018 12:46:46 +0000 (12:46 +0000)
committerHenry Wong <movietravelcode@outlook.com>
Sat, 31 Mar 2018 12:46:46 +0000 (12:46 +0000)
commit695584c53eac778eacfa2785b5bf21e35fdfde8a
treef5083568c89004231772d0ce886a0d32222c7d98
parent70f34b097650d55766afc54d058965aa50d011ea
[analyzer] Unroll the loop when it has a unsigned counter.

Summary:
The original implementation in the `LoopUnrolling.cpp` didn't consider the case where the counter is unsigned. This case is only handled in `simpleCondition()`, but this is not enough, we also need to deal with the unsinged counter with the counter initialization.

Since `IntegerLiteral` is `signed`, there is a `ImplicitCastExpr<IntegralCast>` in `unsigned counter = IntergerLiteral`. This patch add the `ignoringParenImpCasts()` in the `IntegerLiteral` matcher.

Reviewers: szepet, a.sidorin, NoQ, george.karpenkov

Reviewed By: szepet, george.karpenkov

Subscribers: xazax.hun, rnkovacs, cfe-commits, MTC

Differential Revision: https://reviews.llvm.org/D45086

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328919 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/LoopUnrolling.cpp
test/Analysis/loop-unrolling.cpp