[cfe-commits] r47190 - in /cfe/trunk: Analysis/GRExprEngine.cpp Analysis/GRSimpleVals.cpp Analysis/GRSimpleVals.h Analysis/GRTransferFuncs.cpp include/clang/Analysis/PathSensitive/GRTransferFuncs.h
Ted Kremenek
kremenek at apple.com
Fri Feb 15 15:15:23 PST 2008
Author: kremenek
Date: Fri Feb 15 17:15:23 2008
New Revision: 47190
URL: http://llvm.org/viewvc/llvm-project?rev=47190&view=rev
Log:
Refactored code for transfer functions for binary operators involving two LValues.
Fixed bug in transfer functions for sizeof(*); we were incorrectly evaluating to
a value of the wrong type.
Fixed bug in transfer functions for compound assignments where we did not properly
handle assignments involving dereferences of symbolic values.
Modified:
cfe/trunk/Analysis/GRExprEngine.cpp
cfe/trunk/Analysis/GRSimpleVals.cpp
cfe/trunk/Analysis/GRSimpleVals.h
cfe/trunk/Analysis/GRTransferFuncs.cpp
cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47190&r1=47189&r2=47190&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Fri Feb 15 17:15:23 2008
@@ -473,7 +473,7 @@
Nodify(Dst, S, Pred,
SetValue(Pred->getState(), S,
- NonLValue::GetValue(ValMgr, size, getContext().IntTy, L)));
+ NonLValue::GetValue(ValMgr, size, S->getType(), L)));
}
@@ -573,7 +573,7 @@
Nodify(Dst, U, N1,
SetValue(St, U, NonLValue::GetValue(ValMgr, size,
- getContext().IntTy, L)));
+ U->getType(), L)));
break;
}
@@ -730,15 +730,20 @@
Result = EvalBinaryOp(ValMgr, Op, L1, L2);
}
else {
+ QualType T1 = B->getLHS()->getType();
+ QualType T2 = B->getRHS()->getType();
+
// An operation between two variables of a non-lvalue type.
Result =
EvalBinaryOp(ValMgr, Op,
- cast<NonLValue>(GetValue(N1->getState(), L1)),
- cast<NonLValue>(GetValue(N2->getState(), L2)));
+ cast<NonLValue>(GetValue(N1->getState(), L1, &T1)),
+ cast<NonLValue>(GetValue(N2->getState(), L2, &T2)));
}
}
else { // Any other operation between two Non-LValues.
- const NonLValue& R1 = cast<NonLValue>(GetValue(N1->getState(), L1));
+ QualType T = B->getLHS()->getType();
+ const NonLValue& R1 = cast<NonLValue>(GetValue(N1->getState(),
+ L1, &T));
const NonLValue& R2 = cast<NonLValue>(V2);
Result = EvalBinaryOp(ValMgr, Op, R1, R2);
}
Modified: cfe/trunk/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.cpp?rev=47190&r1=47189&r2=47190&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/Analysis/GRSimpleVals.cpp Fri Feb 15 17:15:23 2008
@@ -163,6 +163,24 @@
}
+// Binary Operators (except assignments and comma).
+
+RValue GRSimpleVals::EvalBinaryOp(ValueManager& ValMgr,
+ BinaryOperator::Opcode Op,
+ LValue LHS, LValue RHS) {
+
+ switch (Op) {
+ default:
+ return UnknownVal();
+
+ case BinaryOperator::EQ:
+ return EvalEQ(ValMgr, LHS, RHS);
+
+ case BinaryOperator::NE:
+ return EvalNE(ValMgr, LHS, RHS);
+ }
+}
+
// Pointer arithmetic.
LValue GRSimpleVals::EvalBinaryOp(ValueManager& ValMgr,
Modified: cfe/trunk/Analysis/GRSimpleVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.h?rev=47190&r1=47189&r2=47190&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.h (original)
+++ cfe/trunk/Analysis/GRSimpleVals.h Fri Feb 15 17:15:23 2008
@@ -44,14 +44,19 @@
BinaryOperator::Opcode Op,
NonLValue LHS, NonLValue RHS);
+ virtual RValue EvalBinaryOp(ValueManager& ValMgr,
+ BinaryOperator::Opcode Op,
+ LValue LHS, LValue RHS);
+
// Pointer arithmetic.
virtual LValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
LValue LHS, NonLValue RHS);
+protected:
// Equality operators for LValues.
- virtual NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS);
- virtual NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS);
+ NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS);
+ NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS);
};
Modified: cfe/trunk/Analysis/GRTransferFuncs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRTransferFuncs.cpp?rev=47190&r1=47189&r2=47190&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRTransferFuncs.cpp (original)
+++ cfe/trunk/Analysis/GRTransferFuncs.cpp Fri Feb 15 17:15:23 2008
@@ -39,21 +39,3 @@
return X;
}
-
-// Binary Operators (except assignments and comma).
-
-RValue GRTransferFuncs::EvalBinaryOp(ValueManager& ValMgr,
- BinaryOperator::Opcode Op,
- LValue LHS, LValue RHS) {
-
- switch (Op) {
- default:
- assert (false && "Not yet implemented.");
-
- case BinaryOperator::EQ:
- return EvalEQ(ValMgr, LHS, RHS);
-
- case BinaryOperator::NE:
- return EvalNE(ValMgr, LHS, RHS);
- }
-}
\ No newline at end of file
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=47190&r1=47189&r2=47190&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Fri Feb 15 17:15:23 2008
@@ -43,9 +43,9 @@
BinaryOperator::Opcode Op,
NonLValue LHS, NonLValue RHS) = 0;
- RValue EvalBinaryOp(ValueManager& ValMgr,
- BinaryOperator::Opcode Op,
- LValue LHS, LValue RHS);
+ virtual RValue EvalBinaryOp(ValueManager& ValMgr,
+ BinaryOperator::Opcode Op,
+ LValue LHS, LValue RHS) = 0;
// Pointer arithmetic.
@@ -64,11 +64,6 @@
else
return EvalBinaryOp(ValMgr, Op, cast<NonLValue>(L), cast<NonLValue>(R));
}
-
-
- // Equality operators for LValues.
- virtual NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS) = 0;
- virtual NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS) = 0;
};
} // end clang namespace
More information about the cfe-commits
mailing list