summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-09-04 19:34:58 +0000
committerJordan Rose <jordan_rose@apple.com>2012-09-04 19:34:58 +0000
commit7523d1a847b661d0a8cc71f8aa051c873278445a (patch)
treef712e604a31e509e7b129ecf169d42fd67340f64 /clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
parent7a204359dc0f577770be16c44216fc9e19675f3f (diff)
downloadbcm5719-llvm-7523d1a847b661d0a8cc71f8aa051c873278445a.tar.gz
bcm5719-llvm-7523d1a847b661d0a8cc71f8aa051c873278445a.zip
[analyzer] Don't use makeIntVal to create a floating-point value.
SimpleSValBuilder processes a couple trivial identities, including 'x - x' and 'x ^ x' (both 0). However, the former could appear with arguments of floating-point type, and we weren't checking for that. This started triggering an assert with r163069, which checks that a constant value is actually going to be used as an integer or pointer. llvm-svn: 163159
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index ad58a07c784..1a22845874a 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -318,7 +318,9 @@ SVal SimpleSValBuilder::evalBinOpNN(ProgramStateRef state,
return makeTruthVal(false, resultTy);
case BO_Xor:
case BO_Sub:
- return makeIntVal(0, resultTy);
+ if (resultTy->isIntegralOrEnumerationType())
+ return makeIntVal(0, resultTy);
+ return evalCastFromNonLoc(makeIntVal(0, /*Unsigned=*/false), resultTy);
case BO_Or:
case BO_And:
return evalCastFromNonLoc(lhs, resultTy);
OpenPOWER on IntegriCloud