diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-04-09 07:39:46 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-04-09 07:39:46 +0000 |
commit | c565b63a7905347a51249fafbcaf41b177a22bf0 (patch) | |
tree | b594080b9f50d5db8520c48f7d3a699676e4cdf2 | |
parent | 021887efe6927c6a572e836ff02a5d71912ee0e0 (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
-rw-r--r-- | include/clang/Analysis/PathSensitive/SVals.h | 2 | ||||
-rw-r--r-- | lib/Analysis/GRSimpleVals.cpp | 53 | ||||
-rw-r--r-- | lib/Analysis/SVals.cpp | 2 |
3 files changed, 21 insertions, 36 deletions
diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h index 9d9d9d8091..f3a2d369e7 100644 --- a/include/clang/Analysis/PathSensitive/SVals.h +++ b/include/clang/Analysis/PathSensitive/SVals.h @@ -226,8 +226,6 @@ public: static Loc MakeVal(AddrLabelExpr* E); - static Loc MakeVal(SymbolRef sym); - static Loc MakeNull(BasicValueFactory &BasicVals); // Implement isa<T> support. 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: diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp index ddb2da611f..b78eea72c9 100644 --- a/lib/Analysis/SVals.cpp +++ b/lib/Analysis/SVals.cpp @@ -338,8 +338,6 @@ Loc Loc::MakeVal(const MemRegion* R) { return loc::MemRegionVal(R); } Loc Loc::MakeVal(AddrLabelExpr* E) { return loc::GotoLabel(E->getLabel()); } -Loc Loc::MakeVal(SymbolRef sym) { return loc::SymbolVal(sym); } - Loc Loc::MakeNull(BasicValueFactory &BasicVals) { return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth()); } |