Added boilerplate transfer function support for pointer arithmetic operations.

llvm-svn: 47147
This commit is contained in:
Ted Kremenek 2008-02-15 00:52:26 +00:00
parent e161afc4dd
commit bc0ba39a1e
5 changed files with 35 additions and 2 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -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

View File

@ -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;