[cfe-commits] r47126 - in /cfe/trunk: Analysis/GRExprEngine.cpp Analysis/GRSimpleVals.cpp Analysis/GRSimpleVals.h Analysis/RValues.cpp include/clang/Analysis/PathSensitive/GRTransferFuncs.h include/clang/Analysis/PathSensitive/RValues.h
Ted Kremenek
kremenek at apple.com
Thu Feb 14 10:40:24 PST 2008
Author: kremenek
Date: Thu Feb 14 12:40:24 2008
New Revision: 47126
URL: http://llvm.org/viewvc/llvm-project?rev=47126&view=rev
Log:
Migrated transfer functions for unary "~" and "-" to GRTransferFuncs/GRSimpleVals.
Modified:
cfe/trunk/Analysis/GRExprEngine.cpp
cfe/trunk/Analysis/GRSimpleVals.cpp
cfe/trunk/Analysis/GRSimpleVals.h
cfe/trunk/Analysis/RValues.cpp
cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h
Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47126&r1=47125&r2=47126&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Thu Feb 14 12:40:24 2008
@@ -325,6 +325,14 @@
return TF.EvalCast(ValMgr, R, CastExpr);
}
+ inline NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X) {
+ return TF.EvalMinus(ValMgr, U, X);
+ }
+
+ inline NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X) {
+ return TF.EvalComplement(ValMgr, X);
+ }
};
} // end anonymous namespace
@@ -839,13 +847,13 @@
case UnaryOperator::Minus: {
const NonLValue& R1 = cast<NonLValue>(GetValue(St, U->getSubExpr()));
- Nodify(Dst, U, N1, SetValue(St, U, R1.EvalMinus(ValMgr, U)));
+ Nodify(Dst, U, N1, SetValue(St, U, EvalMinus(ValMgr, U, R1)));
break;
}
case UnaryOperator::Not: {
const NonLValue& R1 = cast<NonLValue>(GetValue(St, U->getSubExpr()));
- Nodify(Dst, U, N1, SetValue(St, U, R1.EvalComplement(ValMgr)));
+ Nodify(Dst, U, N1, SetValue(St, U, EvalComplement(ValMgr, R1)));
break;
}
Modified: cfe/trunk/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.cpp?rev=47126&r1=47125&r2=47126&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/Analysis/GRSimpleVals.cpp Thu Feb 14 12:40:24 2008
@@ -56,4 +56,26 @@
V.extOrTrunc(ValMgr.getContext().getTypeSize(T, CastExpr->getLocStart()));
return nonlval::ConcreteInt(ValMgr.getValue(V));
-}
\ No newline at end of file
+}
+
+// Unary operators.
+
+NonLValue GRSimpleVals::EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X) {
+
+ switch (X.getSubKind()) {
+ case nonlval::ConcreteIntKind:
+ return cast<nonlval::ConcreteInt>(X).EvalMinus(ValMgr, U);
+ default:
+ return cast<NonLValue>(UnknownVal());
+ }
+}
+
+NonLValue GRSimpleVals::EvalComplement(ValueManager& ValMgr, NonLValue X) {
+ switch (X.getSubKind()) {
+ case nonlval::ConcreteIntKind:
+ return cast<nonlval::ConcreteInt>(X).EvalComplement(ValMgr);
+ default:
+ return cast<NonLValue>(UnknownVal());
+ }
+}
Modified: cfe/trunk/Analysis/GRSimpleVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.h?rev=47126&r1=47125&r2=47126&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.h (original)
+++ cfe/trunk/Analysis/GRSimpleVals.h Thu Feb 14 12:40:24 2008
@@ -25,8 +25,17 @@
GRSimpleVals() {}
virtual ~GRSimpleVals() {}
+ // Casts.
+
virtual RValue EvalCast(ValueManager& ValMgr, NonLValue V, Expr* CastExpr);
virtual RValue EvalCast(ValueManager& ValMgr, LValue V, Expr* CastExpr);
+
+ // Unary Operators.
+
+ virtual NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X);
+
+ virtual NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X);
};
Modified: cfe/trunk/Analysis/RValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.cpp?rev=47126&r1=47125&r2=47126&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.cpp (original)
+++ cfe/trunk/Analysis/RValues.cpp Thu Feb 14 12:40:24 2008
@@ -243,14 +243,6 @@
// Bitwise-Complement.
-NonLValue NonLValue::EvalComplement(ValueManager& ValMgr) const {
- switch (getSubKind()) {
- case nonlval::ConcreteIntKind:
- return cast<nonlval::ConcreteInt>(this)->EvalComplement(ValMgr);
- default:
- return cast<NonLValue>(UnknownVal());
- }
-}
nonlval::ConcreteInt
nonlval::ConcreteInt::EvalComplement(ValueManager& ValMgr) const {
@@ -259,15 +251,6 @@
// Unary Minus.
-NonLValue NonLValue::EvalMinus(ValueManager& ValMgr, UnaryOperator* U) const {
- switch (getSubKind()) {
- case nonlval::ConcreteIntKind:
- return cast<nonlval::ConcreteInt>(this)->EvalMinus(ValMgr, U);
- default:
- return cast<NonLValue>(UnknownVal());
- }
-}
-
nonlval::ConcreteInt
nonlval::ConcreteInt::EvalMinus(ValueManager& ValMgr, UnaryOperator* U) const {
assert (U->getType() == U->getSubExpr()->getType());
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=47126&r1=47125&r2=47126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Thu Feb 14 12:40:24 2008
@@ -24,11 +24,19 @@
GRTransferFuncs() {}
virtual ~GRTransferFuncs() {}
+ // Casts.
+
RValue EvalCast(ValueManager& ValMgr, RValue V, Expr* CastExpr);
virtual RValue EvalCast(ValueManager& ValMgr, NonLValue V, Expr* CastExpr) =0;
virtual RValue EvalCast(ValueManager& ValMgr, LValue V, Expr* CastExpr) = 0;
+ // Unary Operators.
+ virtual NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X) = 0;
+
+ virtual NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X) = 0;
+
};
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h?rev=47126&r1=47125&r2=47126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h Thu Feb 14 12:40:24 2008
@@ -325,9 +325,6 @@
NonLValue EvalBinaryOp(ValueManager& ValMgr,
BinaryOperator::Opcode Op,
const NonLValue& RHS) const;
-
- NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U) const;
- NonLValue EvalComplement(ValueManager& ValMgr) const;
// Utility methods to create NonLValues.
static NonLValue GetValue(ValueManager& ValMgr, uint64_t X, QualType T,
More information about the cfe-commits
mailing list