summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2017-08-28 21:15:21 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2017-08-28 21:15:21 +0000
commitb2950aaf270aca9d823cc877f9e6e0c59ba780f3 (patch)
treeb56d3266c534647241799a26ac2bd3256366fbaf /lib/StaticAnalyzer
parent9b4f3545532e0212c4a5317f9669f02645214f4c (diff)
downloadclang-b2950aaf270aca9d823cc877f9e6e0c59ba780f3.tar.gz
[analyzer] Fix crash in modeling arithmetic
This diff fixes modeling of arithmetic expressions where pointers are treated as integers (i.e. via C-style / reinterpret casts). For now we return UnknownVal unless the operation is a comparison. Test plan: make check-all Differential revision: https://reviews.llvm.org/D37120 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311935 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r--lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index a424338342..2ccc747b66 100644
--- a/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -360,10 +360,18 @@ SVal SimpleSValBuilder::evalBinOpNN(ProgramStateRef state,
Loc lhsL = lhs.castAs<nonloc::LocAsInteger>().getLoc();
switch (rhs.getSubKind()) {
case nonloc::LocAsIntegerKind:
+ // FIXME: at the moment the implementation
+ // of modeling "pointers as integers" is not complete.
+ if (!BinaryOperator::isComparisonOp(op))
+ return UnknownVal();
return evalBinOpLL(state, op, lhsL,
rhs.castAs<nonloc::LocAsInteger>().getLoc(),
resultTy);
case nonloc::ConcreteIntKind: {
+ // FIXME: at the moment the implementation
+ // of modeling "pointers as integers" is not complete.
+ if (!BinaryOperator::isComparisonOp(op))
+ return UnknownVal();
// Transform the integer into a location and compare.
// FIXME: This only makes sense for comparisons. If we want to, say,
// add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,