This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Unroll the loop when it has a unsigned counter.
ClosedPublic

Authored by MTC on Mar 30 2018, 6:33 AM.

Details

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.

Diff Detail

Repository
rC Clang

Event Timeline

MTC created this revision.Mar 30 2018, 6:33 AM
MTC edited the summary of this revision. (Show Details)Mar 30 2018, 6:34 AM

Looks reasonable

This revision is now accepted and ready to land.Mar 30 2018, 10:33 AM
szepet accepted this revision.Mar 30 2018, 12:00 PM

Yepp, thanks for the patch! One small typo below.

test/Analysis/loop-unrolling.cpp
50

typo: unsigned

MTC updated this revision to Diff 140524.Mar 30 2018, 8:40 PM

Fix typo, unsinged -> unsigned

This revision was automatically updated to reflect the committed changes.