summaryrefslogtreecommitdiffstats
path: root/clang/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
commit18d77984fb4dd3bc710610e0fd457ddf1d64d225 (patch)
treea38e77357620aedae89336dcbd08f4f906d2a7d1 /clang/lib/StaticAnalyzer
parente4dca92b4e492b1a40ae66958a64738d6bfc0fdc (diff)
downloadbcm5719-llvm-18d77984fb4dd3bc710610e0fd457ddf1d64d225.tar.gz
bcm5719-llvm-18d77984fb4dd3bc710610e0fd457ddf1d64d225.zip
[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 llvm-svn: 311935
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index a424338342b..2ccc747b66e 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud