diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-02-06 04:31:33 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-02-06 04:31:33 +0000 |
| commit | d17f05435a27419645b29b22db403fb883e5179f (patch) | |
| tree | 80bdfe6834862fdd008dc112597ef747edc40e7a /clang/Analysis/GRConstants.cpp | |
| parent | b2652827e6bf82a0c7f48f8f3c836ff385b3f415 (diff) | |
| download | bcm5719-llvm-d17f05435a27419645b29b22db403fb883e5179f.tar.gz bcm5719-llvm-d17f05435a27419645b29b22db403fb883e5179f.zip | |
Fixed signedness bug in cast transfer function when casting integers to pointers.
Removed lval::SymIntConstraintVal; wrappers for symbolic constraints are not lvalues (only integers that evaluate to !0 or 0).
llvm-svn: 46796
Diffstat (limited to 'clang/Analysis/GRConstants.cpp')
| -rw-r--r-- | clang/Analysis/GRConstants.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/Analysis/GRConstants.cpp b/clang/Analysis/GRConstants.cpp index 39a50a55ce2..8656d776c86 100644 --- a/clang/Analysis/GRConstants.cpp +++ b/clang/Analysis/GRConstants.cpp @@ -234,6 +234,9 @@ public: StateTy AssumeSymEQ(StateTy St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); + StateTy AssumeSymInt(StateTy St, bool Assumption, const SymIntConstraint& C, + bool& isFeasible); + void Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, StateTy St); /// Nodify - This version of Nodify is used to batch process a set of states. @@ -874,6 +877,7 @@ GRConstants::StateTy GRConstants::Assume(StateTy St, LValue Cond, return AssumeSymEQ(St, cast<lval::SymbolVal>(Cond).getSymbol(), ValMgr.getZeroWithPtrWidth(), isFeasible); + case lval::DeclValKind: isFeasible = Assumption; return St; @@ -895,6 +899,12 @@ GRConstants::StateTy GRConstants::Assume(StateTy St, NonLValue Cond, assert (false && "'Assume' not implemented for this NonLValue."); return St; + case nonlval::SymIntConstraintValKind: + return + AssumeSymInt(St, Assumption, + cast<nonlval::SymIntConstraintVal>(Cond).getConstraint(), + isFeasible); + case nonlval::ConcreteIntKind: { bool b = cast<nonlval::ConcreteInt>(Cond).getValue() != 0; isFeasible = b ? Assumption : !Assumption; @@ -949,6 +959,29 @@ GRConstants::AssumeSymEQ(StateTy St, SymbolID sym, return StateMgr.AddEQ(St, sym, V); } +GRConstants::StateTy +GRConstants::AssumeSymInt(StateTy St, bool Assumption, + const SymIntConstraint& C, bool& isFeasible) { + + switch (C.getOpcode()) { + default: + // No logic yet for other operators. + return St; + + case BinaryOperator::EQ: + if (Assumption) + return AssumeSymEQ(St, C.getSymbol(), C.getInt(), isFeasible); + else + return AssumeSymNE(St, C.getSymbol(), C.getInt(), isFeasible); + + case BinaryOperator::NE: + if (Assumption) + return AssumeSymNE(St, C.getSymbol(), C.getInt(), isFeasible); + else + return AssumeSymEQ(St, C.getSymbol(), C.getInt(), isFeasible); + } +} + //===----------------------------------------------------------------------===// // Driver. //===----------------------------------------------------------------------===// |

