[cfe-commits] r47357 - in /cfe/trunk: Analysis/GRExprEngine.cpp Analysis/GRSimpleVals.cpp Analysis/GRSimpleVals.h Analysis/RValues.cpp include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h include/clang/Analysis/PathSensitive/RValues.h
Ted Kremenek
kremenek at apple.com
Tue Feb 19 20:12:32 PST 2008
Author: kremenek
Date: Tue Feb 19 22:12:31 2008
New Revision: 47357
URL: http://llvm.org/viewvc/llvm-project?rev=47357&view=rev
Log:
Implemented transfer function logic for unary '+'
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/GRExprEngine.h
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=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Tue Feb 19 22:12:31 2008
@@ -670,6 +670,12 @@
break;
}
+ case UnaryOperator::Plus: {
+ const NonLValue& R1 = cast<NonLValue>(GetValue(St, U->getSubExpr()));
+ Nodify(Dst, U, N1, SetValue(St, U, EvalPlus(ValMgr, U, R1)));
+ break;
+ }
+
case UnaryOperator::Not: {
const NonLValue& R1 = cast<NonLValue>(GetValue(St, U->getSubExpr()));
Nodify(Dst, U, N1, SetValue(St, U, EvalComplement(ValMgr, R1)));
Modified: cfe/trunk/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.cpp?rev=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/Analysis/GRSimpleVals.cpp Tue Feb 19 22:12:31 2008
@@ -112,6 +112,20 @@
}
}
+NonLValue GRSimpleVals::EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X) {
+
+ assert (!isa<UnknownVal>(X) && !isa<UninitializedVal>(X));
+
+ switch (X.getSubKind()) {
+ case nonlval::ConcreteIntKind:
+ return cast<nonlval::ConcreteInt>(X).EvalPlus(ValMgr, U);
+ default:
+ return cast<NonLValue>(UnknownVal());
+ }
+}
+
+
NonLValue GRSimpleVals::EvalComplement(ValueManager& ValMgr, NonLValue X) {
assert (!isa<UnknownVal>(X) && !isa<UninitializedVal>(X));
Modified: cfe/trunk/Analysis/GRSimpleVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.h?rev=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.h (original)
+++ cfe/trunk/Analysis/GRSimpleVals.h Tue Feb 19 22:12:31 2008
@@ -36,6 +36,9 @@
virtual NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
NonLValue X);
+ virtual NonLValue EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X);
+
virtual NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X);
// Binary Operators.
Modified: cfe/trunk/Analysis/RValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.cpp?rev=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.cpp (original)
+++ cfe/trunk/Analysis/RValues.cpp Tue Feb 19 22:12:31 2008
@@ -77,6 +77,13 @@
return ValMgr.getValue(-getValue());
}
+nonlval::ConcreteInt
+nonlval::ConcreteInt::EvalPlus(ValueManager& ValMgr, UnaryOperator* U) const {
+ assert (U->getType() == U->getSubExpr()->getType());
+ assert (U->getType()->isIntegerType());
+ return ValMgr.getValue(getValue());
+}
+
//===----------------------------------------------------------------------===//
// Transfer function dispatch for LValues.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Tue Feb 19 22:12:31 2008
@@ -347,6 +347,14 @@
return TF->EvalMinus(ValMgr, U, X);
}
+ inline NonLValue EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X) {
+ if (isa<UnknownVal>(X) || isa<UninitializedVal>(X))
+ return X;
+
+ return TF->EvalPlus(ValMgr, U, X);
+ }
+
inline NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X) {
if (isa<UnknownVal>(X) || isa<UninitializedVal>(X))
return X;
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=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Tue Feb 19 22:12:31 2008
@@ -35,6 +35,9 @@
virtual NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
NonLValue X) = 0;
+ virtual NonLValue EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
+ NonLValue X) = 0;
+
virtual NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X) = 0;
// Binary Operators.
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=47357&r1=47356&r2=47357&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h Tue Feb 19 22:12:31 2008
@@ -198,6 +198,7 @@
ConcreteInt EvalComplement(ValueManager& ValMgr) const;
ConcreteInt EvalMinus(ValueManager& ValMgr, UnaryOperator* U) const;
+ ConcreteInt EvalPlus(ValueManager& ValMgr, UnaryOperator* U) const;
// Implement isa<T> support.
static inline bool classof(const RValue* V) {
More information about the cfe-commits
mailing list