[cfe-commits] r148011 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h include/clang/StaticAnalyzer/Core/PathSensitive/Store.h lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp lib/StaticAnalyzer/Core/RegionStore.cpp

Anna Zaks ganna at apple.com
Wed Jan 11 18:22:40 PST 2012


Author: zaks
Date: Wed Jan 11 20:22:40 2012
New Revision: 148011

URL: http://llvm.org/viewvc/llvm-project?rev=148011&view=rev
Log:
[analyzer] Rename Store::Retrieve() -> getBinding().

+ all the other Retrieve..() methods + a comment for ElementRegion.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
    cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=148011&r1=148010&r2=148011&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Wed Jan 11 20:22:40 2012
@@ -887,6 +887,7 @@
   void dump() const;
 };
 
+/// \brief ElementRegin is used to represent both array elements and casts.
 class ElementRegion : public TypedValueRegion {
   friend class MemRegionManager;
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=148011&r1=148010&r2=148011&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Wed Jan 11 20:22:40 2012
@@ -728,11 +728,12 @@
 }
 
 inline SVal ProgramState::getRawSVal(Loc LV, QualType T) const {
-  return getStateManager().StoreMgr->Retrieve(getStore(), LV, T);
+  return getStateManager().StoreMgr->getBinding(getStore(), LV, T);
 }
 
 inline SVal ProgramState::getSVal(const MemRegion* R) const {
-  return getStateManager().StoreMgr->Retrieve(getStore(), loc::MemRegionVal(R));
+  return getStateManager().StoreMgr->getBinding(getStore(),
+                                                loc::MemRegionVal(R));
 }
 
 inline BasicValueFactory &ProgramState::getBasicVals() const {

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h?rev=148011&r1=148010&r2=148011&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h Wed Jan 11 20:22:40 2012
@@ -55,7 +55,7 @@
   ///   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 SVal Retrieve(Store store, Loc loc, QualType T = QualType()) = 0;
+  virtual SVal getBinding(Store store, 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/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=148011&r1=148010&r2=148011&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Wed Jan 11 20:22:40 2012
@@ -133,7 +133,7 @@
                 return true;
             }
             else {
-              const SVal &V = StoreMgr.Retrieve(store, loc::MemRegionVal(FR));
+              const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
               if (V.isUndef())
                 return true;
             }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=148011&r1=148010&r2=148011&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp Wed Jan 11 20:22:40 2012
@@ -224,7 +224,7 @@
 
   if (const loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(&ArgV)) {
     StoreManager& SM = C.getStoreManager();
-    const MemRegion *V = SM.Retrieve(State->getStore(), *X).getAsRegion();
+    const MemRegion *V = SM.getBinding(State->getStore(), *X).getAsRegion();
     if (V)
       return getSymbolForRegion(C, V);
   }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=148011&r1=148010&r2=148011&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Wed Jan 11 20:22:40 2012
@@ -279,7 +279,8 @@
     RegionBindings B = GetRegionBindings(store);
     assert(!lookup(B, R, BindingKey::Default));
     assert(!lookup(B, R, BindingKey::Direct));
-    return StoreRef(addBinding(B, R, BindingKey::Default, V).getRootWithoutRetain(), *this);
+    return StoreRef(addBinding(B, R, BindingKey::Default, V)
+                      .getRootWithoutRetain(), *this);
   }
 
   StoreRef BindCompoundLiteral(Store store, const CompoundLiteralExpr *CL,
@@ -314,12 +315,10 @@
   
   bool includedInBindings(Store store, const MemRegion *region) const;
 
-  //===------------------------------------------------------------------===//
-  // Loading values from regions.
-  //===------------------------------------------------------------------===//
-
+  /// \brief Return the value bound to specified location in a given state.
+  ///
   /// The high level logic for this method is this:
-  /// Retrieve (L)
+  /// getBinding (L)
   ///   if L has binding
   ///     return L's binding
   ///   else if L is in killset
@@ -329,39 +328,39 @@
   ///       return undefined
   ///     else
   ///       return symbolic
-  SVal Retrieve(Store store, Loc L, QualType T = QualType());
+  SVal getBinding(Store store, Loc L, QualType T = QualType());
 
-  SVal RetrieveElement(Store store, const ElementRegion *R);
+  SVal getBindingForElement(Store store, const ElementRegion *R);
 
-  SVal RetrieveField(Store store, const FieldRegion *R);
+  SVal getBindingForField(Store store, const FieldRegion *R);
 
-  SVal RetrieveObjCIvar(Store store, const ObjCIvarRegion *R);
+  SVal getBindingForObjCIvar(Store store, const ObjCIvarRegion *R);
 
-  SVal RetrieveVar(Store store, const VarRegion *R);
+  SVal getBindingForVar(Store store, const VarRegion *R);
 
-  SVal RetrieveLazySymbol(const TypedValueRegion *R);
+  SVal getBindingForLazySymbol(const TypedValueRegion *R);
 
-  SVal RetrieveFieldOrElementCommon(Store store, const TypedValueRegion *R,
-                                    QualType Ty, const MemRegion *superR);
+  SVal getBindingForFieldOrElementCommon(Store store, const TypedValueRegion *R,
+                                         QualType Ty, const MemRegion *superR);
   
-  SVal RetrieveLazyBinding(const MemRegion *lazyBindingRegion,
-                           Store lazyBindingStore);
+  SVal getLazyBinding(const MemRegion *lazyBindingRegion,
+                      Store lazyBindingStore);
 
-  /// Retrieve the values in a struct and return a CompoundVal, used when doing
-  /// struct copy:
+  /// Get bindings for the values in a struct and return a CompoundVal, used
+  /// when doing struct copy:
   /// struct s x, y;
   /// x = y;
   /// y's value is retrieved by this method.
-  SVal RetrieveStruct(Store store, const TypedValueRegion* R);
+  SVal getBindingForStruct(Store store, const TypedValueRegion* R);
 
-  SVal RetrieveArray(Store store, const TypedValueRegion* R);
+  SVal getBindingForArray(Store store, const TypedValueRegion* R);
 
   /// Used to lazily generate derived symbols for bindings that are defined
   ///  implicitly by default bindings in a super region.
-  Optional<SVal> RetrieveDerivedDefaultValue(RegionBindings B,
-                                             const MemRegion *superR,
-                                             const TypedValueRegion *R, 
-                                             QualType Ty);
+  Optional<SVal> getBindingForDerivedDefaultValue(RegionBindings B,
+                                                  const MemRegion *superR,
+                                                  const TypedValueRegion *R,
+                                                  QualType Ty);
 
   /// Get the state and region whose binding this region R corresponds to.
   std::pair<Store, const MemRegion*>
@@ -428,7 +427,8 @@
   return new RegionStoreManager(StMgr, F);
 }
 
-StoreManager *ento::CreateFieldsOnlyRegionStoreManager(ProgramStateManager &StMgr) {
+StoreManager *
+ento::CreateFieldsOnlyRegionStoreManager(ProgramStateManager &StMgr) {
   RegionStoreFeatures F = minimal_features_tag();
   F.enableFields(true);
   return new RegionStoreManager(StMgr, F);
@@ -719,7 +719,7 @@
   }
   
 
-  DefinedOrUnknownSVal V = svalBuilder.getConjuredSymbolVal(baseR, Ex, T, Count);
+  DefinedOrUnknownSVal V = svalBuilder.getConjuredSymbolVal(baseR, Ex, T,Count);
   assert(SymbolManager::canSymbolicate(T) || V.isUnknown());
   B = RM.addBinding(B, baseR, BindingKey::Direct, V);
 }
@@ -794,9 +794,10 @@
 // Extents for regions.
 //===----------------------------------------------------------------------===//
 
-DefinedOrUnknownSVal RegionStoreManager::getSizeInElements(const ProgramState *state,
-                                                           const MemRegion *R,
-                                                           QualType EleTy) {
+DefinedOrUnknownSVal
+RegionStoreManager::getSizeInElements(const ProgramState *state,
+                                      const MemRegion *R,
+                                      QualType EleTy) {
   SVal Size = cast<SubRegion>(R)->getExtent(svalBuilder);
   const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
   if (!SizeInt)
@@ -893,7 +894,7 @@
   return Optional<SVal>();
 }
 
-SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) {
+SVal RegionStoreManager::getBinding(Store store, Loc L, QualType T) {
   assert(!isa<UnknownVal>(L) && "location unknown");
   assert(!isa<UndefinedVal>(L) && "location undefined");
 
@@ -937,21 +938,21 @@
   // Such funny addressing will occur due to layering of regions.
 
   if (RTy->isStructureOrClassType())
-    return RetrieveStruct(store, R);
+    return getBindingForStruct(store, R);
 
   // FIXME: Handle unions.
   if (RTy->isUnionType())
     return UnknownVal();
 
   if (RTy->isArrayType())
-    return RetrieveArray(store, R);
+    return getBindingForArray(store, R);
 
   // FIXME: handle Vector types.
   if (RTy->isVectorType())
     return UnknownVal();
 
   if (const FieldRegion* FR = dyn_cast<FieldRegion>(R))
-    return CastRetrievedVal(RetrieveField(store, FR), FR, T, false);
+    return CastRetrievedVal(getBindingForField(store, FR), FR, T, false);
 
   if (const ElementRegion* ER = dyn_cast<ElementRegion>(R)) {
     // FIXME: Here we actually perform an implicit conversion from the loaded
@@ -959,7 +960,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 CastRetrievedVal(RetrieveElement(store, ER), ER, T, false);
+    return CastRetrievedVal(getBindingForElement(store, ER), ER, T, false);
   }
 
   if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R)) {
@@ -969,7 +970,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 CastRetrievedVal(RetrieveObjCIvar(store, IVR), IVR, T, false);
+    return CastRetrievedVal(getBindingForObjCIvar(store, IVR), IVR, T, false);
   }
 
   if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
@@ -979,7 +980,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 CastRetrievedVal(RetrieveVar(store, VR), VR, T, false);
+    return CastRetrievedVal(getBindingForVar(store, VR), VR, T, false);
   }
 
   RegionBindings B = GetRegionBindings(store);
@@ -1049,7 +1050,7 @@
   return std::make_pair((Store) 0, (const MemRegion *) 0);
 }
 
-SVal RegionStoreManager::RetrieveElement(Store store,
+SVal RegionStoreManager::getBindingForElement(Store store,
                                          const ElementRegion* R) {
   // Check if the region has a binding.
   RegionBindings B = GetRegionBindings(store);
@@ -1071,7 +1072,7 @@
     if (nonloc::ConcreteInt *CI = dyn_cast<nonloc::ConcreteInt>(&Idx)) {
       int64_t i = CI->getValue().getSExtValue();
       // Abort on string underrun.  This can be possible by arbitrary
-      // clients of RetrieveElement().
+      // clients of getBindingForElement().
       if (i < 0)
         return UndefinedVal();
       int64_t length = Str->getLength();
@@ -1121,10 +1122,11 @@
       }
     }
   }
-  return RetrieveFieldOrElementCommon(store, R, R->getElementType(), superR);
+  return getBindingForFieldOrElementCommon(store, R, R->getElementType(),
+                                           superR);
 }
 
-SVal RegionStoreManager::RetrieveField(Store store,
+SVal RegionStoreManager::getBindingForField(Store store,
                                        const FieldRegion* R) {
 
   // Check if the region has a binding.
@@ -1133,14 +1135,14 @@
     return *V;
 
   QualType Ty = R->getValueType();
-  return RetrieveFieldOrElementCommon(store, R, Ty, R->getSuperRegion());
+  return getBindingForFieldOrElementCommon(store, R, Ty, R->getSuperRegion());
 }
 
 Optional<SVal>
-RegionStoreManager::RetrieveDerivedDefaultValue(RegionBindings B,
-                                                const MemRegion *superR,
-                                                const TypedValueRegion *R,
-                                                QualType Ty) {
+RegionStoreManager::getBindingForDerivedDefaultValue(RegionBindings B,
+                                                     const MemRegion *superR,
+                                                     const TypedValueRegion *R,
+                                                     QualType Ty) {
 
   if (const Optional<SVal> &D = getDefaultBinding(B, superR)) {
     const SVal &val = D.getValue();
@@ -1163,28 +1165,28 @@
   return Optional<SVal>();
 }
 
-SVal RegionStoreManager::RetrieveLazyBinding(const MemRegion *lazyBindingRegion,
+SVal RegionStoreManager::getLazyBinding(const MemRegion *lazyBindingRegion,
                                              Store lazyBindingStore) {
   if (const ElementRegion *ER = dyn_cast<ElementRegion>(lazyBindingRegion))
-    return RetrieveElement(lazyBindingStore, ER);
+    return getBindingForElement(lazyBindingStore, ER);
   
-  return RetrieveField(lazyBindingStore,
-                       cast<FieldRegion>(lazyBindingRegion));
+  return getBindingForField(lazyBindingStore,
+                            cast<FieldRegion>(lazyBindingRegion));
 }
                                         
-SVal RegionStoreManager::RetrieveFieldOrElementCommon(Store store,
+SVal RegionStoreManager::getBindingForFieldOrElementCommon(Store store,
                                                       const TypedValueRegion *R,
                                                       QualType Ty,
                                                       const MemRegion *superR) {
 
-  // At this point we have already checked in either RetrieveElement or
-  // RetrieveField if 'R' has a direct binding.
+  // At this point we have already checked in either getBindingForElement or
+  // getBindingForField if 'R' has a direct binding.
 
   RegionBindings B = GetRegionBindings(store);
 
   while (superR) {
     if (const Optional<SVal> &D =
-        RetrieveDerivedDefaultValue(B, superR, R, Ty))
+        getBindingForDerivedDefaultValue(B, superR, R, Ty))
       return *D;
 
     // If our super region is a field or element itself, walk up the region
@@ -1202,7 +1204,7 @@
   llvm::tie(lazyBindingStore, lazyBindingRegion) = GetLazyBinding(B, R, R);
 
   if (lazyBindingRegion)
-    return RetrieveLazyBinding(lazyBindingRegion, lazyBindingStore);
+    return getLazyBinding(lazyBindingRegion, lazyBindingStore);
 
   if (R->hasStackNonParametersStorage()) {
     if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
@@ -1227,7 +1229,8 @@
   return svalBuilder.getRegionValueSymbolVal(R);
 }
 
-SVal RegionStoreManager::RetrieveObjCIvar(Store store, const ObjCIvarRegion* R){
+SVal RegionStoreManager::getBindingForObjCIvar(Store store,
+                                               const ObjCIvarRegion* R) {
 
     // Check if the region has a binding.
   RegionBindings B = GetRegionBindings(store);
@@ -1246,10 +1249,10 @@
     return UnknownVal();
   }
 
-  return RetrieveLazySymbol(R);
+  return getBindingForLazySymbol(R);
 }
 
-SVal RegionStoreManager::RetrieveVar(Store store, const VarRegion *R) {
+SVal RegionStoreManager::getBindingForVar(Store store, const VarRegion *R) {
 
   // Check if the region has a binding.
   RegionBindings B = GetRegionBindings(store);
@@ -1281,7 +1284,8 @@
           }
       }
 
-      if (const Optional<SVal> &V = RetrieveDerivedDefaultValue(B, MS, R, CT))
+      if (const Optional<SVal> &V
+            = getBindingForDerivedDefaultValue(B, MS, R, CT))
         return V.getValue();
 
       return svalBuilder.getRegionValueSymbolVal(R);
@@ -1298,19 +1302,19 @@
   return UndefinedVal();
 }
 
-SVal RegionStoreManager::RetrieveLazySymbol(const TypedValueRegion *R) {
+SVal RegionStoreManager::getBindingForLazySymbol(const TypedValueRegion *R) {
   // All other values are symbolic.
   return svalBuilder.getRegionValueSymbolVal(R);
 }
 
-SVal RegionStoreManager::RetrieveStruct(Store store, 
+SVal RegionStoreManager::getBindingForStruct(Store store, 
                                         const TypedValueRegion* R) {
   QualType T = R->getValueType();
   assert(T->isStructureOrClassType());
   return svalBuilder.makeLazyCompoundVal(StoreRef(store, *this), R);
 }
 
-SVal RegionStoreManager::RetrieveArray(Store store, 
+SVal RegionStoreManager::getBindingForArray(Store store, 
                                        const TypedValueRegion * R) {
   assert(Ctx.getAsConstantArrayType(R->getValueType()));
   return svalBuilder.makeLazyCompoundVal(StoreRef(store, *this), R);
@@ -1674,7 +1678,8 @@
   const StackFrameContext *CurrentLCtx;
 
 public:
-  removeDeadBindingsWorker(RegionStoreManager &rm, ProgramStateManager &stateMgr,
+  removeDeadBindingsWorker(RegionStoreManager &rm,
+                           ProgramStateManager &stateMgr,
                            RegionBindings b, SymbolReaper &symReaper,
                            const StackFrameContext *LCtx)
     : ClusterAnalysis<removeDeadBindingsWorker>(rm, stateMgr, b,





More information about the cfe-commits mailing list