diff options
author | Jordy Rose <jediknil@belkadan.com> | 2010-06-27 01:20:56 +0000 |
---|---|---|
committer | Jordy Rose <jediknil@belkadan.com> | 2010-06-27 01:20:56 +0000 |
commit | 7f8ea4d677f2c07f281d0fe3c67895fe1cb93999 (patch) | |
tree | fbced1b1f60500a6e66d46a19d1a6e1c9c398d57 /clang/lib | |
parent | e01d966ce22e90a3d007bbb60a88c6b553bb74b5 (diff) | |
download | bcm5719-llvm-7f8ea4d677f2c07f281d0fe3c67895fe1cb93999.tar.gz bcm5719-llvm-7f8ea4d677f2c07f281d0fe3c67895fe1cb93999.zip |
Implicitly compare symbolic expressions to zero when they're being used as constraints. Part of PR7491.
llvm-svn: 106972
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Checker/SimpleConstraintManager.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Checker/SimpleConstraintManager.cpp b/clang/lib/Checker/SimpleConstraintManager.cpp index a1594a9e9ee..321381b045a 100644 --- a/clang/lib/Checker/SimpleConstraintManager.cpp +++ b/clang/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) |