diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-25 18:44:25 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-25 18:44:25 +0000 |
commit | ff4264dae31cf42807b64ecc114906b0b835690a (patch) | |
tree | 30d7af74b21dcbddfd278996a74cb541bf88183f /lib/Analysis/SValuator.cpp | |
parent | 91cf4199cca311ea9c3b3a4e2b3984d508c9e5e3 (diff) |
Move logic of GRExprEngine::EvalBinOp to SValuator::EvalBinOp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/SValuator.cpp')
-rw-r--r-- | lib/Analysis/SValuator.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Analysis/SValuator.cpp b/lib/Analysis/SValuator.cpp index 079481a62a..2542cfdd3c 100644 --- a/lib/Analysis/SValuator.cpp +++ b/lib/Analysis/SValuator.cpp @@ -17,6 +17,35 @@ using namespace clang; + +SVal SValuator::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op, + SVal L, SVal R, QualType T) { + + if (L.isUndef() || R.isUndef()) + return UndefinedVal(); + + if (L.isUnknown() || R.isUnknown()) + return UnknownVal(); + + if (isa<Loc>(L)) { + if (isa<Loc>(R)) + return EvalBinOpLL(Op, cast<Loc>(L), cast<Loc>(R), T); + + return EvalBinOpLN(ST, Op, cast<Loc>(L), cast<NonLoc>(R), T); + } + + if (isa<Loc>(R)) { + // Support pointer arithmetic where the increment/decrement operand + // is on the left and the pointer on the right. + assert(Op == BinaryOperator::Add || Op == BinaryOperator::Sub); + + // Commute the operands. + return EvalBinOpLN(ST, Op, cast<Loc>(R), cast<NonLoc>(L), T); + } + + return EvalBinOpNN(Op, cast<NonLoc>(L), cast<NonLoc>(R), T); +} + SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state, QualType castTy, QualType originalTy){ |