Fix regression by explicitly checking if we are negating a SymIntConstantVal.

llvm-svn: 53753
This commit is contained in:
Ted Kremenek 2008-07-18 15:54:51 +00:00
parent 6a62d908c3
commit b1c91bfc45
3 changed files with 22 additions and 1 deletions

View File

@ -83,6 +83,8 @@ public:
return getRawKind() > UnknownKind;
}
bool isZeroConstant() const;
void print(std::ostream& OS) const;
void printStdErr() const;

View File

@ -472,11 +472,16 @@ RVal GRSimpleVals::DetermEvalBinOpNN(ValueStateManager& StateMgr,
return UnknownVal();
case nonlval::SymIntConstraintValKind: {
// Logical not?
if (!(Op == BinaryOperator::EQ && R.isZeroConstant()))
return UnknownVal();
const SymIntConstraint& C =
cast<nonlval::SymIntConstraintVal>(L).getConstraint();
BinaryOperator::Opcode Opc = C.getOpcode();
if (Opc < BinaryOperator::LT || Opc > BinaryOperator::NE)
return UnknownVal();

View File

@ -54,6 +54,20 @@ RVal::symbol_iterator RVal::symbol_end() const {
return X ? X+1 : NULL;
}
//===----------------------------------------------------------------------===//
// Useful predicates.
//===----------------------------------------------------------------------===//
bool RVal::isZeroConstant() const {
if (isa<lval::ConcreteInt>(*this))
return cast<lval::ConcreteInt>(*this).getValue() == 0;
else if (isa<nonlval::ConcreteInt>(*this))
return cast<nonlval::ConcreteInt>(*this).getValue() == 0;
else
return false;
}
//===----------------------------------------------------------------------===//
// Transfer function dispatch for Non-LVals.
//===----------------------------------------------------------------------===//