summaryrefslogtreecommitdiffstats
path: root/clang/lib/Checker
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2010-06-30 01:35:20 +0000
committerJordy Rose <jediknil@belkadan.com>2010-06-30 01:35:20 +0000
commitdc484718619994f1d6797ce344e0182f720088a5 (patch)
treeaadc6f61e9b54abeb3c7a3a501659f0af4faef2f /clang/lib/Checker
parentabb04f730e722e2457cabaec14546439f04ac73c (diff)
downloadbcm5719-llvm-dc484718619994f1d6797ce344e0182f720088a5.tar.gz
bcm5719-llvm-dc484718619994f1d6797ce344e0182f720088a5.zip
Pointers casted as integers still count as locations to SimpleSValuator, so don't crash if we do a funny thing like ((int)ptr)&1. Fixes PR7527.
llvm-svn: 107236
Diffstat (limited to 'clang/lib/Checker')
-rw-r--r--clang/lib/Checker/SimpleSValuator.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Checker/SimpleSValuator.cpp b/clang/lib/Checker/SimpleSValuator.cpp
index 0f4fe07bb70..5b24992118c 100644
--- a/clang/lib/Checker/SimpleSValuator.cpp
+++ b/clang/lib/Checker/SimpleSValuator.cpp
@@ -502,7 +502,12 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state,
QualType resultTy) {
// Only comparisons and subtractions are valid operations on two pointers.
// See [C99 6.5.5 through 6.5.14] or [C++0x 5.6 through 5.15].
- assert(BinaryOperator::isComparisonOp(op) || op == BinaryOperator::Sub);
+ // However, if a pointer is casted to an integer, EvalBinOpNN may end up
+ // calling this function with another operation (PR7527). We don't attempt to
+ // model this for now, but it could be useful, particularly when the
+ // "location" is actually an integer value that's been passed through a void*.
+ if (!(BinaryOperator::isComparisonOp(op) || op == BinaryOperator::Sub))
+ return UnknownVal();
// Special cases for when both sides are identical.
if (lhs == rhs) {
OpenPOWER on IntegriCloud