aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-15 00:52:26 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-15 00:52:26 +0000
commitb640b3b5dfccaf259967cb2cb6755c9aa20d4423 (patch)
treec3c08ec210743a13229e0378dfc772d75894554d
parentd55fe520e79960afa796bda53cb4273fb1be4811 (diff)
Added boilerplate transfer function support for pointer arithmetic operations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47147 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Analysis/GRExprEngine.cpp12
-rw-r--r--Analysis/GRSimpleVals.cpp9
-rw-r--r--Analysis/GRSimpleVals.h5
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngine.h5
-rw-r--r--include/clang/Analysis/PathSensitive/GRTransferFuncs.h6
5 files changed, 35 insertions, 2 deletions
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index 15f1aa2e37..bbf06d92fc 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -706,9 +706,17 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
if (isa<LValue>(V1)) {
// FIXME: Add support for RHS being a non-lvalue.
const LValue& L1 = cast<LValue>(V1);
- const LValue& L2 = cast<LValue>(V2);
- Nodify(Dst, B, N2, SetValue(St, B, EvalBinaryOp(ValMgr, Op, L1, L2)));
+ if (isa<LValue>(V2)) {
+ const LValue& L2 = cast<LValue>(V2);
+ Nodify(Dst, B, N2, SetValue(St, B,
+ EvalBinaryOp(ValMgr, Op, L1, L2)));
+ }
+ else {
+ const NonLValue& R2 = cast<NonLValue>(V2);
+ Nodify(Dst, B, N2, SetValue(St, B,
+ EvalBinaryOp(ValMgr, Op, L1, R2)));
+ }
}
else {
const NonLValue& R1 = cast<NonLValue>(V1);
diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp
index e856c3e5d0..c9827d9d10 100644
--- a/Analysis/GRSimpleVals.cpp
+++ b/Analysis/GRSimpleVals.cpp
@@ -162,6 +162,15 @@ NonLValue GRSimpleVals::EvalBinaryOp(ValueManager& ValMgr,
}
}
+
+// Pointer arithmetic.
+
+LValue GRSimpleVals::EvalBinaryOp(ValueManager& ValMgr,
+ BinaryOperator::Opcode Op,
+ LValue LHS, NonLValue RHS) {
+ return cast<LValue>(UnknownVal());
+}
+
// Equality operators for LValues.
diff --git a/Analysis/GRSimpleVals.h b/Analysis/GRSimpleVals.h
index 0f517fe5eb..b00dd3ca39 100644
--- a/Analysis/GRSimpleVals.h
+++ b/Analysis/GRSimpleVals.h
@@ -44,6 +44,11 @@ public:
BinaryOperator::Opcode Op,
NonLValue LHS, NonLValue RHS);
+ // Pointer arithmetic.
+
+ virtual LValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
+ LValue LHS, NonLValue RHS);
+
// Equality operators for LValues.
virtual NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS);
virtual NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS);
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index 1c88b30b88..ffb4420965 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -330,5 +330,10 @@ public:
LValue LHS, LValue RHS) {
return TF->EvalBinaryOp(ValMgr, Op, LHS, RHS);
}
+
+ inline RValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
+ LValue LHS, NonLValue RHS) {
+ return TF->EvalBinaryOp(ValMgr, Op, LHS, RHS);
+ }
};
} // end clang namespace \ No newline at end of file
diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
index b38ac0c91a..87ff170372 100644
--- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
+++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
@@ -47,6 +47,12 @@ public:
BinaryOperator::Opcode Op,
LValue LHS, LValue RHS);
+
+ // Pointer arithmetic.
+
+ virtual LValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
+ LValue LHS, NonLValue RHS) = 0;
+
// Equality operators for LValues.
virtual NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS) = 0;
virtual NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS) = 0;