[cfe-commits] r90503 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/MemRegion.cpp lib/Analysis/RegionStore.cpp lib/Analysis/ValueManager.cpp

Ted Kremenek kremenek at apple.com
Thu Dec 3 16:26:31 PST 2009


Author: kremenek
Date: Thu Dec  3 18:26:31 2009
New Revision: 90503

URL: http://llvm.org/viewvc/llvm-project?rev=90503&view=rev
Log:
constify MemRegion* returned by MemRegionManager::getXXXRegion() methods.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
    cfe/trunk/lib/Analysis/MemRegion.cpp
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/lib/Analysis/ValueManager.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Thu Dec  3 18:26:31 2009
@@ -691,50 +691,50 @@
 
   /// getStackRegion - Retrieve the memory region associated with the
   ///  current stack frame.
-  MemSpaceRegion *getStackRegion();
+  const MemSpaceRegion *getStackRegion();
 
   /// getStackArgumentsRegion - Retrieve the memory region associated with
   ///  function/method arguments of the current stack frame.
-  MemSpaceRegion *getStackArgumentsRegion();
+  const MemSpaceRegion *getStackArgumentsRegion();
 
   /// getGlobalsRegion - Retrieve the memory region associated with
   ///  all global variables.
-  MemSpaceRegion *getGlobalsRegion();
+  const MemSpaceRegion *getGlobalsRegion();
 
   /// getHeapRegion - Retrieve the memory region associated with the
   ///  generic "heap".
-  MemSpaceRegion *getHeapRegion();
+  const MemSpaceRegion *getHeapRegion();
 
   /// getUnknownRegion - Retrieve the memory region associated with unknown
   /// memory space.
-  MemSpaceRegion *getUnknownRegion();
+  const MemSpaceRegion *getUnknownRegion();
 
-  MemSpaceRegion *getCodeRegion();
+  const MemSpaceRegion *getCodeRegion();
 
   /// getAllocaRegion - Retrieve a region associated with a call to alloca().
-  AllocaRegion *getAllocaRegion(const Expr* Ex, unsigned Cnt);
+  const AllocaRegion *getAllocaRegion(const Expr* Ex, unsigned Cnt);
 
   /// getCompoundLiteralRegion - Retrieve the region associated with a
   ///  given CompoundLiteral.
-  CompoundLiteralRegion*
+  const CompoundLiteralRegion*
   getCompoundLiteralRegion(const CompoundLiteralExpr* CL);
 
   /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
-  SymbolicRegion* getSymbolicRegion(SymbolRef sym);
+  const SymbolicRegion* getSymbolicRegion(SymbolRef sym);
 
-  StringRegion* getStringRegion(const StringLiteral* Str);
+  const StringRegion* getStringRegion(const StringLiteral* Str);
 
   /// getVarRegion - Retrieve or create the memory region associated with
   ///  a specified VarDecl and LocationContext.
-  VarRegion* getVarRegion(const VarDecl *D, const LocationContext *LC);
+  const VarRegion* getVarRegion(const VarDecl *D, const LocationContext *LC);
 
   /// getElementRegion - Retrieve the memory region associated with the
   ///  associated element type, index, and super region.
-  ElementRegion *getElementRegion(QualType elementType, SVal Idx,
+  const ElementRegion *getElementRegion(QualType elementType, SVal Idx,
                                   const MemRegion *superRegion,
                                   ASTContext &Ctx);
 
-  ElementRegion *getElementRegionWithSuper(const ElementRegion *ER,
+  const ElementRegion *getElementRegionWithSuper(const ElementRegion *ER,
                                            const MemRegion *superRegion) {
     return getElementRegion(ER->getElementType(), ER->getIndex(),
                             superRegion, ER->getContext());
@@ -744,29 +744,30 @@
   ///  a specified FieldDecl.  'superRegion' corresponds to the containing
   ///  memory region (which typically represents the memory representing
   ///  a structure or class).
-  FieldRegion *getFieldRegion(const FieldDecl* fd,
-                              const MemRegion* superRegion);
+  const FieldRegion *getFieldRegion(const FieldDecl* fd,
+                                    const MemRegion* superRegion);
 
-  FieldRegion *getFieldRegionWithSuper(const FieldRegion *FR,
-                                       const MemRegion *superRegion) {
+  const FieldRegion *getFieldRegionWithSuper(const FieldRegion *FR,
+                                             const MemRegion *superRegion) {
     return getFieldRegion(FR->getDecl(), superRegion);
   }
 
   /// getObjCObjectRegion - Retrieve or create the memory region associated with
   ///  the instance of a specified Objective-C class.
-  ObjCObjectRegion* getObjCObjectRegion(const ObjCInterfaceDecl* ID,
-                                  const MemRegion* superRegion);
+  const ObjCObjectRegion* getObjCObjectRegion(const ObjCInterfaceDecl* ID,
+                                              const MemRegion* superRegion);
 
   /// getObjCIvarRegion - Retrieve or create the memory region associated with
   ///   a specified Objective-c instance variable.  'superRegion' corresponds
   ///   to the containing region (which typically represents the Objective-C
   ///   object).
-  ObjCIvarRegion *getObjCIvarRegion(const ObjCIvarDecl* ivd,
-                                    const MemRegion* superRegion);
+  const ObjCIvarRegion *getObjCIvarRegion(const ObjCIvarDecl* ivd,
+                                          const MemRegion* superRegion);
 
-  FunctionTextRegion *getFunctionTextRegion(const FunctionDecl *FD);
-  BlockTextRegion *getBlockTextRegion(const BlockDecl *BD, CanQualType locTy);
-  BlockDataRegion *getBlockDataRegion(const BlockTextRegion *bc,
+  const FunctionTextRegion *getFunctionTextRegion(const FunctionDecl *FD);
+  const BlockTextRegion *getBlockTextRegion(const BlockDecl *BD,
+                                            CanQualType locTy);
+  const BlockDataRegion *getBlockDataRegion(const BlockTextRegion *bc,
                                       const LocationContext *lc);
 
   bool isGlobalsRegion(const MemRegion* R) {
@@ -788,7 +789,7 @@
   RegionTy* getSubRegion(const A1 a1, const A2 a2,
                          const MemRegion* superRegion);
 
-  MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);
+  const MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);
 };
 
 //===----------------------------------------------------------------------===//

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

==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Thu Dec  3 18:26:31 2009
@@ -404,7 +404,7 @@
 // MemRegionManager methods.
 //===----------------------------------------------------------------------===//
 
-MemSpaceRegion* MemRegionManager::LazyAllocate(MemSpaceRegion*& region) {
+const MemSpaceRegion *MemRegionManager::LazyAllocate(MemSpaceRegion*& region) {
   if (!region) {
     region = (MemSpaceRegion*) A.Allocate<MemSpaceRegion>();
     new (region) MemSpaceRegion(this);
@@ -413,27 +413,27 @@
   return region;
 }
 
-MemSpaceRegion* MemRegionManager::getStackRegion() {
+const MemSpaceRegion *MemRegionManager::getStackRegion() {
   return LazyAllocate(stack);
 }
 
-MemSpaceRegion* MemRegionManager::getStackArgumentsRegion() {
+const MemSpaceRegion *MemRegionManager::getStackArgumentsRegion() {
   return LazyAllocate(stackArguments);
 }
 
-MemSpaceRegion* MemRegionManager::getGlobalsRegion() {
+const MemSpaceRegion *MemRegionManager::getGlobalsRegion() {
   return LazyAllocate(globals);
 }
 
-MemSpaceRegion* MemRegionManager::getHeapRegion() {
+const MemSpaceRegion *MemRegionManager::getHeapRegion() {
   return LazyAllocate(heap);
 }
 
-MemSpaceRegion* MemRegionManager::getUnknownRegion() {
+const MemSpaceRegion *MemRegionManager::getUnknownRegion() {
   return LazyAllocate(unknown);
 }
 
-MemSpaceRegion* MemRegionManager::getCodeRegion() {
+const MemSpaceRegion *MemRegionManager::getCodeRegion() {
   return LazyAllocate(code);
 }
 
@@ -441,12 +441,12 @@
 // Constructing regions.
 //===----------------------------------------------------------------------===//
 
-StringRegion* MemRegionManager::getStringRegion(const StringLiteral* Str) {
+const StringRegion* MemRegionManager::getStringRegion(const StringLiteral* Str) {
   return getRegion<StringRegion>(Str);
 }
 
-VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
-                                          const LocationContext *LC) {
+const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
+                                                const LocationContext *LC) {
 
   // FIXME: Once we implement scope handling, we will need to properly lookup
   // 'D' to the proper LocationContext.  For now, just strip down to the
@@ -457,9 +457,9 @@
   return getRegion<VarRegion>(D, LC);
 }
 
-BlockDataRegion *MemRegionManager::getBlockDataRegion(const BlockTextRegion *BC,
-                                                      const LocationContext *LC)
-{
+const BlockDataRegion *
+MemRegionManager::getBlockDataRegion(const BlockTextRegion *BC,
+                                     const LocationContext *LC) {
   // FIXME: Once we implement scope handling, we will need to properly lookup
   // 'D' to the proper LocationContext.  For now, just strip down to the
   // StackFrame.
@@ -469,12 +469,12 @@
   return getSubRegion<BlockDataRegion>(BC, LC, getStackRegion());
 }
 
-CompoundLiteralRegion*
+const CompoundLiteralRegion*
 MemRegionManager::getCompoundLiteralRegion(const CompoundLiteralExpr* CL) {
   return getRegion<CompoundLiteralRegion>(CL);
 }
 
-ElementRegion*
+const ElementRegion*
 MemRegionManager::getElementRegion(QualType elementType, SVal Idx,
                                    const MemRegion* superRegion,
                                    ASTContext& Ctx){
@@ -497,40 +497,42 @@
   return R;
 }
 
-FunctionTextRegion *
+const FunctionTextRegion *
 MemRegionManager::getFunctionTextRegion(const FunctionDecl *FD) {
   return getRegion<FunctionTextRegion>(FD);
 }
 
-BlockTextRegion *MemRegionManager::getBlockTextRegion(const BlockDecl *BD,
-                                                      CanQualType locTy) {
+const BlockTextRegion *
+MemRegionManager::getBlockTextRegion(const BlockDecl *BD, CanQualType locTy) {
   return getRegion<BlockTextRegion>(BD, locTy);
 }
 
 
 /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
-SymbolicRegion* MemRegionManager::getSymbolicRegion(SymbolRef sym) {
+const SymbolicRegion *MemRegionManager::getSymbolicRegion(SymbolRef sym) {
   return getRegion<SymbolicRegion>(sym);
 }
 
-FieldRegion* MemRegionManager::getFieldRegion(const FieldDecl* d,
-                                              const MemRegion* superRegion) {
+const FieldRegion *
+MemRegionManager::getFieldRegion(const FieldDecl* d,
+                                 const MemRegion* superRegion){
   return getSubRegion<FieldRegion>(d, superRegion);
 }
 
-ObjCIvarRegion*
+const ObjCIvarRegion*
 MemRegionManager::getObjCIvarRegion(const ObjCIvarDecl* d,
                                     const MemRegion* superRegion) {
   return getSubRegion<ObjCIvarRegion>(d, superRegion);
 }
 
-ObjCObjectRegion*
+const ObjCObjectRegion*
 MemRegionManager::getObjCObjectRegion(const ObjCInterfaceDecl* d,
                                       const MemRegion* superRegion) {
   return getSubRegion<ObjCObjectRegion>(d, superRegion);
 }
 
-AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
+const AllocaRegion*
+MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
   return getRegion<AllocaRegion>(E, cnt);
 }
 

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Dec  3 18:26:31 2009
@@ -820,9 +820,8 @@
   T = AT->getElementType();
 
   SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
-  ElementRegion* ER = MRMgr.getElementRegion(T, ZeroIdx, ArrayR, getContext());
-
-  return loc::MemRegionVal(ER);
+  return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx, ArrayR,
+                                                  getContext()));
 }
 
 //===----------------------------------------------------------------------===//
@@ -1465,9 +1464,7 @@
 RegionStoreManager::BindCompoundLiteral(const GRState *state,
                                         const CompoundLiteralExpr* CL,
                                         SVal V) {
-
-  CompoundLiteralRegion* R = MRMgr.getCompoundLiteralRegion(CL);
-  return Bind(state, loc::MemRegionVal(R), V);
+  return Bind(state, loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL)), V);
 }
 
 const GRState *RegionStoreManager::setImplicitDefaultValue(const GRState *state,
@@ -1520,8 +1517,8 @@
         break;
 
       SVal Idx = ValMgr.makeArrayIndex(i);
-      ElementRegion* ER = MRMgr.getElementRegion(ElementTy, Idx, R,
-                                                 getContext());
+      const ElementRegion* ER = MRMgr.getElementRegion(ElementTy, Idx, R,
+                                                       getContext());
 
       SVal V = ValMgr.makeIntVal(str[j], sizeof(char)*8, true);
       state = Bind(state, loc::MemRegionVal(ER), V);
@@ -1549,7 +1546,7 @@
       break;
 
     SVal Idx = ValMgr.makeArrayIndex(i);
-    ElementRegion* ER = MRMgr.getElementRegion(ElementTy, Idx, R, getContext());
+    const ElementRegion *ER = MRMgr.getElementRegion(ElementTy, Idx, R, getContext());
 
     if (CAT->getElementType()->isStructureType())
       state = BindStruct(state, ER, *VI);
@@ -1871,8 +1868,7 @@
   // Copy the arg expression value to the arg variables.
   for (; AI != AE; ++AI, ++PI) {
     SVal ArgVal = state->getSVal(*AI);
-    MemRegion *R = MRMgr.getVarRegion(*PI, frame);
-    state = Bind(state, ValMgr.makeLoc(R), ArgVal);
+    state = Bind(state, ValMgr.makeLoc(MRMgr.getVarRegion(*PI, frame)), ArgVal);
   }
 
   return state;

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

==============================================================================
--- cfe/trunk/lib/Analysis/ValueManager.cpp (original)
+++ cfe/trunk/lib/Analysis/ValueManager.cpp Thu Dec  3 18:26:31 2009
@@ -138,15 +138,14 @@
 }
 
 DefinedSVal ValueManager::getFunctionPointer(const FunctionDecl* FD) {
-  CodeTextRegion *R  = MemMgr.getFunctionTextRegion(FD);
-  return loc::MemRegionVal(R);
+  return loc::MemRegionVal(MemMgr.getFunctionTextRegion(FD));
 }
 
 DefinedSVal ValueManager::getBlockPointer(const BlockDecl *D,
                                           CanQualType locTy,
                                           const LocationContext *LC) {
-  BlockTextRegion *BC = MemMgr.getBlockTextRegion(D, locTy);
-  BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, LC);
+  const BlockTextRegion *BC = MemMgr.getBlockTextRegion(D, locTy);
+  const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, LC);
   return loc::MemRegionVal(BD);
 }
 





More information about the cfe-commits mailing list