aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/SimpleConstraintManager.cpp
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2010-06-27 01:20:56 +0000
committerJordy Rose <jediknil@belkadan.com>2010-06-27 01:20:56 +0000
commit5ca129c2558a13d7d4b2b76fee8404bc07466ce9 (patch)
tree2f60aac8e0282aab78e48cbb816e3f731b0fd779 /lib/Checker/SimpleConstraintManager.cpp
parentf70d857cbd79b24cb69f4990e31175e95e679a31 (diff)
Implicitly compare symbolic expressions to zero when they're being used as constraints. Part of PR7491.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106972 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/SimpleConstraintManager.cpp')
-rw-r--r--lib/Checker/SimpleConstraintManager.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Checker/SimpleConstraintManager.cpp b/lib/Checker/SimpleConstraintManager.cpp
index a1594a9e9e..321381b045 100644
--- a/lib/Checker/SimpleConstraintManager.cpp
+++ b/lib/Checker/SimpleConstraintManager.cpp
@@ -174,9 +174,13 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
return state;
BinaryOperator::Opcode op = SE->getOpcode();
- // FIXME: We should implicitly compare non-comparison expressions to 0.
- if (!BinaryOperator::isComparisonOp(op))
- return state;
+ // Implicitly compare non-comparison expressions to 0.
+ if (!BinaryOperator::isComparisonOp(op)) {
+ QualType T = SymMgr.getType(SE);
+ const llvm::APSInt &zero = BasicVals.getValue(0, T);
+ op = (Assumption ? BinaryOperator::NE : BinaryOperator::EQ);
+ return AssumeSymRel(state, SE, op, zero);
+ }
// From here on out, op is the real comparison we'll be testing.
if (!Assumption)