[cfe-commits] r68703 - in /cfe/trunk: include/clang/Analysis/PathSensitive/SVals.h lib/Analysis/GRSimpleVals.cpp lib/Analysis/SVals.cpp

Zhongxing Xu xuzhongxing at gmail.com
Thu Apr 9 00:39:46 PDT 2009


Author: zhongxingxu
Date: Thu Apr  9 02:39:46 2009
New Revision: 68703

URL: http://llvm.org/viewvc/llvm-project?rev=68703&view=rev
Log:
stop using loc::SymbolVal and clean up code with new API.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
    cfe/trunk/lib/Analysis/GRSimpleVals.cpp
    cfe/trunk/lib/Analysis/SVals.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=68703&r1=68702&r2=68703&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Thu Apr  9 02:39:46 2009
@@ -226,8 +226,6 @@
     
   static Loc MakeVal(AddrLabelExpr* E);
 
-  static Loc MakeVal(SymbolRef sym);
-  
   static Loc MakeNull(BasicValueFactory &BasicVals);
   
   // Implement isa<T> support.

Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=68703&r1=68702&r2=68703&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Thu Apr  9 02:39:46 2009
@@ -260,32 +260,20 @@
   }
 }
 
-// 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 @@
     }
       
     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 @@
   
   BasicValueFactory& BasicVals = Eng.getBasicVals();
 
-TryAgain:
   switch (L.getSubKind()) {
 
     default:
@@ -407,15 +395,16 @@
     }
       
     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:

Modified: cfe/trunk/lib/Analysis/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=68703&r1=68702&r2=68703&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/SVals.cpp (original)
+++ cfe/trunk/lib/Analysis/SVals.cpp Thu Apr  9 02:39:46 2009
@@ -338,8 +338,6 @@
 
 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());
 }





More information about the cfe-commits mailing list