[cfe-commits] r95279 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRState.h include/clang/Checker/PathSensitive/Store.h lib/Checker/BasicStore.cpp lib/Checker/FlatStore.cpp lib/Checker/RegionStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Feb 3 18:39:48 PST 2010


Author: zhongxingxu
Date: Wed Feb  3 20:39:47 2010
New Revision: 95279

URL: http://llvm.org/viewvc/llvm-project?rev=95279&view=rev
Log:
Now that CastRetrievedVal returns SVal, there is no need to use CastResult.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
    cfe/trunk/include/clang/Checker/PathSensitive/Store.h
    cfe/trunk/lib/Checker/BasicStore.cpp
    cfe/trunk/lib/Checker/FlatStore.cpp
    cfe/trunk/lib/Checker/RegionStore.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRState.h?rev=95279&r1=95278&r2=95279&view=diff

==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRState.h Wed Feb  3 20:39:47 2010
@@ -671,11 +671,11 @@
 }
 
 inline SVal GRState::getSVal(Loc LV, QualType T) const {
-  return getStateManager().StoreMgr->Retrieve(this, LV, T).getSVal();
+  return getStateManager().StoreMgr->Retrieve(this, LV, T);
 }
 
 inline SVal GRState::getSVal(const MemRegion* R) const {
-  return getStateManager().StoreMgr->Retrieve(this, loc::MemRegionVal(R)).getSVal();
+  return getStateManager().StoreMgr->Retrieve(this, loc::MemRegionVal(R));
 }
 
 inline BasicValueFactory &GRState::getBasicVals() const {

Modified: cfe/trunk/include/clang/Checker/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Store.h?rev=95279&r1=95278&r2=95279&view=diff

==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/Store.h Wed Feb  3 20:39:47 2010
@@ -54,8 +54,8 @@
   ///   expected type of the returned value.  This is used if the value is
   ///   lazily computed.
   /// \return The value bound to the location \c loc.
-  virtual SValuator::CastResult Retrieve(const GRState *state, Loc loc,
-                                         QualType T = QualType()) = 0;
+  virtual SVal Retrieve(const GRState *state, Loc loc, QualType T = QualType())
+                                                                            = 0;
 
   /// Return a state with the specified value bound to the given location.
   /// \param[in] state The analysis state.

Modified: cfe/trunk/lib/Checker/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BasicStore.cpp?rev=95279&r1=95278&r2=95279&view=diff

==============================================================================
--- cfe/trunk/lib/Checker/BasicStore.cpp (original)
+++ cfe/trunk/lib/Checker/BasicStore.cpp Wed Feb  3 20:39:47 2010
@@ -44,8 +44,7 @@
     return new BasicStoreSubRegionMap();
   }
 
-  SValuator::CastResult Retrieve(const GRState *state, Loc loc,
-                                 QualType T = QualType());
+  SVal Retrieve(const GRState *state, Loc loc, QualType T = QualType());
 
   const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
                                   const Expr *E, unsigned Count,
@@ -250,11 +249,9 @@
   }
 }
 
-SValuator::CastResult BasicStoreManager::Retrieve(const GRState *state,
-                                                  Loc loc, QualType T) {
-
+SVal BasicStoreManager::Retrieve(const GRState *state, Loc loc, QualType T) {
   if (isa<UnknownVal>(loc))
-    return SValuator::CastResult(state, UnknownVal());
+    return UnknownVal();
 
   assert(!isa<UndefinedVal>(loc));
 
@@ -264,7 +261,7 @@
       const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
 
       if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
-        return SValuator::CastResult(state, UnknownVal());
+        return UnknownVal();
 
       BindingsTy B = GetBindings(state->getStore());
       BindingsTy::data_type *Val = B.lookup(R);
@@ -272,22 +269,21 @@
       if (!Val)
         break;
 
-      return SValuator::CastResult(state,
-                              CastRetrievedVal(*Val, cast<TypedRegion>(R), T));
+      return CastRetrievedVal(*Val, cast<TypedRegion>(R), T);
     }
 
     case loc::ConcreteIntKind:
       // Some clients may call GetSVal with such an option simply because
       // they are doing a quick scan through their Locs (potentially to
       // invalidate their bindings).  Just return Undefined.
-      return SValuator::CastResult(state, UndefinedVal());
+      return UndefinedVal();
 
     default:
       assert (false && "Invalid Loc.");
       break;
   }
 
-  return SValuator::CastResult(state, UnknownVal());
+  return UnknownVal();
 }
 
 Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
@@ -398,7 +394,7 @@
           break;
 
         Marked.insert(MR);
-        SVal X = Retrieve(&state, loc::MemRegionVal(MR)).getSVal();
+        SVal X = Retrieve(&state, loc::MemRegionVal(MR));
 
         // FIXME: We need to handle symbols nested in region definitions.
         for (symbol_iterator SI=X.symbol_begin(),SE=X.symbol_end();SI!=SE;++SI)

Modified: cfe/trunk/lib/Checker/FlatStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/FlatStore.cpp?rev=95279&r1=95278&r2=95279&view=diff

==============================================================================
--- cfe/trunk/lib/Checker/FlatStore.cpp (original)
+++ cfe/trunk/lib/Checker/FlatStore.cpp Wed Feb  3 20:39:47 2010
@@ -27,7 +27,7 @@
       RBFactory(mgr.getAllocator()), 
       BVFactory(mgr.getAllocator()) {}
 
-  SValuator::CastResult Retrieve(const GRState *state, Loc loc, QualType T);
+  SVal Retrieve(const GRState *state, Loc loc, QualType T);
   const GRState *Bind(const GRState *state, Loc loc, SVal val);
   Store Remove(Store St, Loc L);
   const GRState *BindCompoundLiteral(const GRState *state,
@@ -73,9 +73,8 @@
   return new FlatStoreManager(StMgr);
 }
 
-SValuator::CastResult FlatStoreManager::Retrieve(const GRState *state, Loc loc,
-                                                 QualType T) {
-  return SValuator::CastResult(state, UnknownVal());
+SVal FlatStoreManager::Retrieve(const GRState *state, Loc loc, QualType T) {
+  return UnknownVal();
 }
 
 const GRState *FlatStoreManager::Bind(const GRState *state, Loc loc, SVal val) {

Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=95279&r1=95278&r2=95279&view=diff

==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Wed Feb  3 20:39:47 2010
@@ -355,8 +355,7 @@
   ///       return undefined
   ///     else
   ///       return symbolic
-  SValuator::CastResult Retrieve(const GRState *state, Loc L,
-                                 QualType T = QualType());
+  SVal Retrieve(const GRState *state, Loc L, QualType T = QualType());
 
   SVal RetrieveElement(const GRState *state, const ElementRegion *R);
 
@@ -1095,19 +1094,15 @@
   assert(!T.isNull());
   return MRMgr.getElementRegion(T, idx, SR, Ctx);
 }
-  
-  
-
-SValuator::CastResult
-RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
 
+SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
   assert(!isa<UnknownVal>(L) && "location unknown");
   assert(!isa<UndefinedVal>(L) && "location undefined");
   
   // FIXME: Is this even possible?  Shouldn't this be treated as a null
   //  dereference at a higher level?
   if (isa<loc::ConcreteInt>(L))
-    return SValuator::CastResult(state, UndefinedVal());
+    return UndefinedVal();
   
   const MemRegion *MR = cast<loc::MemRegionVal>(L).getRegion();
 
@@ -1118,13 +1113,13 @@
   // read(p);
   // c = *p;
   if (isa<AllocaRegion>(MR))
-    return SValuator::CastResult(state, UnknownVal());
+    return UnknownVal();
 
   if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR))
     MR = GetElementZeroRegion(SR, T);
 
   if (isa<CodeTextRegion>(MR))
-    return SValuator::CastResult(state, UnknownVal());
+    return UnknownVal();
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument
   //  instead of 'Loc', and have the other Loc cases handled at a higher level.
@@ -1152,23 +1147,21 @@
 #endif
 
   if (RTy->isStructureType())
-    return SValuator::CastResult(state, RetrieveStruct(state, R));
+    return RetrieveStruct(state, R);
 
   // FIXME: Handle unions.
   if (RTy->isUnionType())
-    return SValuator::CastResult(state, UnknownVal());
+    return UnknownVal();
 
   if (RTy->isArrayType())
-    return SValuator::CastResult(state, RetrieveArray(state, R));
+    return RetrieveArray(state, R);
 
   // FIXME: handle Vector types.
   if (RTy->isVectorType())
-    return SValuator::CastResult(state, UnknownVal());
+    return UnknownVal();
 
   if (const FieldRegion* FR = dyn_cast<FieldRegion>(R))
-    return SValuator::CastResult(state, 
-                                 CastRetrievedVal(RetrieveField(state, FR), FR,
-                                                  T, false));
+    return CastRetrievedVal(RetrieveField(state, FR), FR, T, false);
 
   if (const ElementRegion* ER = dyn_cast<ElementRegion>(R)) {
     // FIXME: Here we actually perform an implicit conversion from the loaded
@@ -1176,9 +1169,7 @@
     // more intelligently.  For example, an 'element' can encompass multiple
     // bound regions (e.g., several bound bytes), or could be a subset of
     // a larger value.
-    return SValuator::CastResult(state,
-                                 CastRetrievedVal(RetrieveElement(state, ER),
-                                                  ER, T, false));
+    return CastRetrievedVal(RetrieveElement(state, ER), ER, T, false);
   }    
 
   if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R)) {
@@ -1188,9 +1179,7 @@
     // reinterpretted, it is possible we stored a different value that could
     // fit within the ivar.  Either we need to cast these when storing them
     // or reinterpret them lazily (as we do here).
-    return SValuator::CastResult(state,
-                                 CastRetrievedVal(RetrieveObjCIvar(state, IVR),
-                                                  IVR, T, false));
+    return CastRetrievedVal(RetrieveObjCIvar(state, IVR), IVR, T, false);
   }
 
   if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
@@ -1200,9 +1189,7 @@
     // variable is reinterpretted, it is possible we stored a different value
     // that could fit within the variable.  Either we need to cast these when
     // storing them or reinterpret them lazily (as we do here).    
-    return SValuator::CastResult(state,
-                                 CastRetrievedVal(RetrieveVar(state, VR), VR, T,
-                                                  false));
+    return CastRetrievedVal(RetrieveVar(state, VR), VR, T, false);
   }
 
   RegionBindings B = GetRegionBindings(state->getStore());
@@ -1210,7 +1197,7 @@
 
   // Check if the region has a binding.
   if (V)
-      return SValuator::CastResult(state, *V);
+    return *V;
 
   // The location does not have a bound value.  This means that it has
   // the value it had upon its creation and/or entry to the analyzed
@@ -1220,11 +1207,11 @@
     // upon creation.  All heap allocated blocks are considered to
     // have undefined values as well unless they are explicitly bound
     // to specific values.
-    return SValuator::CastResult(state, UndefinedVal());
+    return UndefinedVal();
   }
 
   // All other values are symbolic.
-  return SValuator::CastResult(state, ValMgr.getRegionValueSymbolVal(R, RTy));
+  return ValMgr.getRegionValueSymbolVal(R, RTy);
 }
 
 std::pair<const GRState*, const MemRegion*>





More information about the cfe-commits mailing list