[cfe-commits] r46796 - in /cfe/trunk/Analysis: GRConstants.cpp RValues.cpp RValues.h
Ted Kremenek
kremenek at apple.com
Tue Feb 5 20:31:34 PST 2008
Author: kremenek
Date: Tue Feb 5 22:31:33 2008
New Revision: 46796
URL: http://llvm.org/viewvc/llvm-project?rev=46796&view=rev
Log:
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).
Modified:
cfe/trunk/Analysis/GRConstants.cpp
cfe/trunk/Analysis/RValues.cpp
cfe/trunk/Analysis/RValues.h
Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46796&r1=46795&r2=46796&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Tue Feb 5 22:31:33 2008
@@ -234,6 +234,9 @@
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 @@
return AssumeSymEQ(St, cast<lval::SymbolVal>(Cond).getSymbol(),
ValMgr.getZeroWithPtrWidth(), isFeasible);
+
case lval::DeclValKind:
isFeasible = Assumption;
return St;
@@ -895,6 +899,12 @@
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 @@
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.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Analysis/RValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.cpp?rev=46796&r1=46795&r2=46796&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.cpp (original)
+++ cfe/trunk/Analysis/RValues.cpp Tue Feb 5 22:31:33 2008
@@ -138,7 +138,7 @@
APSInt V = cast<nonlval::ConcreteInt>(this)->getValue();
QualType T = CastExpr->getType();
- V.setIsUnsigned(T->isUnsignedIntegerType());
+ V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType());
V.extOrTrunc(ValMgr.getContext().getTypeSize(T, CastExpr->getLocStart()));
if (CastExpr->getType()->isPointerType())
@@ -425,17 +425,7 @@
case lval::SymbolValKind:
Out << '$' << cast<lval::SymbolVal>(this)->getSymbol();
break;
-
- case lval::SymIntConstraintValKind: {
- const lval::SymIntConstraintVal& C =
- *cast<lval::SymIntConstraintVal>(this);
-
- Out << '$' << C.getConstraint().getSymbol() << ' ';
- printOpcode(Out, C.getConstraint().getOpcode());
- Out << ' ' << C.getConstraint().getInt().toString();
- break;
- }
-
+
case lval::DeclValKind:
Out << '&'
<< cast<lval::DeclVal>(this)->getDecl()->getIdentifier()->getName();
Modified: cfe/trunk/Analysis/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.h?rev=46796&r1=46795&r2=46796&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.h (original)
+++ cfe/trunk/Analysis/RValues.h Tue Feb 5 22:31:33 2008
@@ -446,7 +446,6 @@
namespace lval {
enum Kind { SymbolValKind,
- SymIntConstraintValKind,
DeclValKind,
ConcreteIntKind,
NumKind };
@@ -465,20 +464,6 @@
}
};
- class SymIntConstraintVal : public LValue {
- public:
- SymIntConstraintVal(const SymIntConstraint& C)
- : LValue(SymIntConstraintValKind, reinterpret_cast<const void*>(&C)) {}
-
- const SymIntConstraint& getConstraint() const {
- return *reinterpret_cast<SymIntConstraint*>(getRawPtr());
- }
-
- static inline bool classof(const RValue* V) {
- return isa<LValue>(V) && V->getSubKind() == SymIntConstraintValKind;
- }
- };
-
class DeclVal : public LValue {
public:
DeclVal(const ValueDecl* vd) : LValue(DeclValKind,vd) {}
More information about the cfe-commits
mailing list