aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRSimpleVals.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-04-09 07:39:46 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-04-09 07:39:46 +0000
commitc565b63a7905347a51249fafbcaf41b177a22bf0 (patch)
treeb594080b9f50d5db8520c48f7d3a699676e4cdf2 /lib/Analysis/GRSimpleVals.cpp
parent021887efe6927c6a572e836ff02a5d71912ee0e0 (diff)
stop using loc::SymbolVal and clean up code with new API.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRSimpleVals.cpp')
-rw-r--r--lib/Analysis/GRSimpleVals.cpp53
1 files changed, 21 insertions, 32 deletions
diff --git a/lib/Analysis/GRSimpleVals.cpp b/lib/Analysis/GRSimpleVals.cpp
index dfc9d4eb1c..44e76555f9 100644
--- a/lib/Analysis/GRSimpleVals.cpp
+++ b/lib/Analysis/GRSimpleVals.cpp
@@ -260,32 +260,20 @@ SVal GRSimpleVals::EvalBinOp(GRExprEngine& Eng, BinaryOperator::Opcode Op,
}
}
-// Pointer arithmetic.
-static Loc StripViews(Loc X) {
- if (isa<loc::MemRegionVal>(X)) {
- const SymbolicRegion *Region =
- cast<loc::MemRegionVal>(X).getRegion()->getAs<SymbolicRegion>();
-
- if (Region)
- return Loc::MakeVal(Region->getSymbol());
- }
-
- return X;
-}
-
SVal GRSimpleVals::EvalBinOp(GRExprEngine& Eng, BinaryOperator::Opcode Op,
Loc L, NonLoc R) {
// Delegate pointer arithmetic to store manager.
return Eng.getStoreManager().EvalBinOp(Op, L, R);
}
-// Equality operators for Locs.
+// Equality operators for Locs.
+// FIXME: All this logic will be revamped when we have MemRegion::getLocation()
+// implemented.
SVal GRSimpleVals::EvalEQ(GRExprEngine& Eng, Loc L, Loc R) {
BasicValueFactory& BasicVals = Eng.getBasicVals();
-TryAgain:
switch (L.getSubKind()) {
default:
@@ -335,14 +323,15 @@ TryAgain:
}
case loc::MemRegionKind: {
- // See if 'L' and 'R' both wrap symbols.
- Loc LTmp = StripViews(L);
- Loc RTmp = StripViews(R);
-
- if (LTmp != L || RTmp != R) {
- L = LTmp;
- R = RTmp;
- goto TryAgain;
+ if (SymbolRef LSym = L.getAsLocSymbol()) {
+ if (isa<loc::ConcreteInt>(R)) {
+ const SymIntExpr *SE =
+ Eng.getSymbolManager().getSymIntExpr(LSym, BinaryOperator::EQ,
+ cast<loc::ConcreteInt>(R).getValue(),
+ Eng.getContext().IntTy);
+
+ return nonloc::SymExprVal(SE);
+ }
}
}
@@ -360,7 +349,6 @@ SVal GRSimpleVals::EvalNE(GRExprEngine& Eng, Loc L, Loc R) {
BasicValueFactory& BasicVals = Eng.getBasicVals();
-TryAgain:
switch (L.getSubKind()) {
default:
@@ -407,15 +395,16 @@ TryAgain:
}
case loc::MemRegionKind: {
- // See if 'L' and 'R' both wrap symbols.
- Loc LTmp = StripViews(L);
- Loc RTmp = StripViews(R);
-
- if (LTmp != L || RTmp != R) {
- L = LTmp;
- R = RTmp;
- goto TryAgain;
+ if (SymbolRef LSym = L.getAsLocSymbol()) {
+ if (isa<loc::ConcreteInt>(R)) {
+ const SymIntExpr* SE =
+ Eng.getSymbolManager().getSymIntExpr(LSym, BinaryOperator::NE,
+ cast<loc::ConcreteInt>(R).getValue(),
+ Eng.getContext().IntTy);
+ return nonloc::SymExprVal(SE);
+ }
}
+ // Fall through:
}
case loc::FuncValKind: