]> granicus.if.org Git - clang/commitdiff
stop using loc::SymbolVal and clean up code with new API.
authorZhongxing Xu <xuzhongxing@gmail.com>
Thu, 9 Apr 2009 07:39:46 +0000 (07:39 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Thu, 9 Apr 2009 07:39:46 +0000 (07:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68703 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/SVals.h
lib/Analysis/GRSimpleVals.cpp
lib/Analysis/SVals.cpp

index 9d9d9d8091ab6aa7d778d75352bbf83ec7eeccd5..f3a2d369e750a1ac0a309164c5dff2cb3debcefd 100644 (file)
@@ -226,8 +226,6 @@ public:
     
   static Loc MakeVal(AddrLabelExpr* E);
 
-  static Loc MakeVal(SymbolRef sym);
-  
   static Loc MakeNull(BasicValueFactory &BasicVals);
   
   // Implement isa<T> support.
index dfc9d4eb1ce4367fba2ef34b549ed0ce5746d5e5..44e76555f942c9a026193999af5c1c6f3bd694f9 100644 (file)
@@ -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:
index ddb2da611fb9fbc2448f93e496718de4ba5460f3..b78eea72c9f306fe72ab27345a4c390bce313c4c 100644 (file)
@@ -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());
 }