[cfe-dev] Fwd: [analyzer] false positive in loop?

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 3 02:09:28 PST 2015


I think this case is of an actual false positive:

(1) Our constraint solver (RangeConstraintManager) is very simple and 
doesn't yet handle constraints like "x is odd" properly. Not quite sure, 
in fact maybe at least adding a "== 0" range on the SymIntExpr "x % 2" 
should have helped, why don't we do at least that? I'd have had a look.

(2) If IntegerList::at() is not inlined properly (doesn't have its body 
available for analysis), then the analyzer would not realize that the 
symbol checked in hasEvenNumbers() is the same symbol that is checked in 
walkthrough(); at() may return a different value, and blindly assuming 
this value to be the same (eg. assuming all unknown functions to be 
pure) would make things a lot worse. This is a more complicated work of 
supporting (evalCall'ing or BodyFarm'ing) STL containers, assuming 
IntegerList is a typedef for some std::list<int>, or if you use custom 
containers, then you need to have a checker to support them, or 
inter-unit analysis may be of use if the body of container methods is in 
fact available, just in another translation unit.



More information about the cfe-dev mailing list