summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-07-31 19:26:34 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-07-31 19:26:34 +0000
commit05220a900cf8309fcdbe3e82344c65081b730374 (patch)
tree9de95c3fa2d2e3b6edef91748a41edeed332c23f /clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
parentdeb471fa15a323de839997a4add2709f53cfacfa (diff)
downloadbcm5719-llvm-05220a900cf8309fcdbe3e82344c65081b730374.tar.gz
bcm5719-llvm-05220a900cf8309fcdbe3e82344c65081b730374.zip
[analyzer] Don't try to simplify mixed Loc/NonLoc expressions.
This fix is similar to r337769 and addresses a regression caused by r337167. When an operation between a nonloc::LocAsInteger and a non-pointer symbol is performed, the LocAsInteger-specific part of information is lost. When the non-pointer symbol is collapsing into a constant, we cannot easily re-evaluate the result, because we need to recover the missing LocAsInteger-specific information (eg., integer type, or the very fact that this pointer was at some point converted to an integer). Add one more defensive check to prevent crashes on trying to simplify a SymSymExpr with different Loc-ness of operands. Differential Revision: llvm-svn: 338420
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index dbbb516441e..6509ec30eea 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1291,6 +1291,17 @@ SVal SimpleSValBuilder::simplifySVal(ProgramStateRef State, SVal V) {
if (I != Cached.end())
return I->second;
+ // For now don't try to simplify mixed Loc/NonLoc expressions
+ // because they often appear from LocAsInteger operations
+ // and we don't know how to combine a LocAsInteger
+ // with a concrete value.
+ if (Loc::isLocType(S->getLHS()->getType()) !=
+ Loc::isLocType(S->getRHS()->getType())) {
+ SVal V = SVB.makeSymbolVal(S);
+ Cached[S] = V;
+ return V;
+ }
+
SVal LHS = Visit(S->getLHS());
SVal RHS = Visit(S->getRHS());
if (isUnchanged(S->getLHS(), LHS) && isUnchanged(S->getRHS(), RHS)) {
OpenPOWER on IntegriCloud