[PATCH] D37120: [analyzer] Fix modeling arithmetic
Alexander Shaposhnikov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 25 11:49:14 PDT 2017
alexshap added inline comments.
================
Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:363
case nonloc::LocAsIntegerKind:
return evalBinOpLL(state, op, lhsL,
rhs.castAs<nonloc::LocAsInteger>().getLoc(),
----------------
@NoQ , @dcoughlin
while we are looking at this code - just to double check - is this line (363) actually correct ?
Let's take a look at the following example:
bool f(long x, double *p1, double *p2) {
long y = (long)p1 - (long) p2;
// or,alternatively (long)p1 * (long)p2 or (long)p1 / (long)p2
return y == x;
}
it looks like again the analyzer will try to use evalBinOpLL and evaluate this as an operation over pointers, while (if my understanding is correct) we should be working with integers here (and yes, in most cases it should return UnknownVal)
Repository:
rL LLVM
https://reviews.llvm.org/D37120
More information about the cfe-commits
mailing list