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

Zhongxing Xu xuzhongxing at gmail.com
Wed Dec 10 18:27:38 PST 2008


Author: zhongxingxu
Date: Wed Dec 10 20:27:34 2008
New Revision: 60868

URL: http://llvm.org/viewvc/llvm-project?rev=60868&view=rev
Log:
AnonPointeeRegions are now identified by the MemRegion of the pointer pointing
to them.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
    cfe/trunk/lib/Analysis/MemRegion.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=60868&r1=60867&r2=60868&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Wed Dec 10 20:27:34 2008
@@ -237,20 +237,21 @@
 ///  parameters or pointer globals. In RegionStoreManager, we assume pointer
 ///  parameters or globals point at some anonymous region. Such regions are not
 ///  the regions associated with the pointer variables themselves.  They are
-///  identified with the VarDecl of the pointer variable. We create them lazily.
+///  identified by the MemRegion of the pointer pointing to them. We create
+///  them lazily.
 
 class AnonPointeeRegion : public TypedRegion {
   friend class MemRegionManager;
   // VD - the pointer variable that points at this region.
-  const VarDecl* Pointer;
+  const TypedRegion* Pointer;
 
-  AnonPointeeRegion(const VarDecl* d, MemRegion* sreg)
-    : TypedRegion(sreg, AnonPointeeRegionKind), Pointer(d) {}
+  AnonPointeeRegion(const TypedRegion* r, MemRegion* sreg)
+    : TypedRegion(sreg, AnonPointeeRegionKind), Pointer(r) {}
 
 public:
   QualType getType(ASTContext& C) const;
 
-  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* PVD,
+  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const TypedRegion* R,
                             const MemRegion* superRegion);
 
   void Profile(llvm::FoldingSetNodeID& ID) const {
@@ -518,7 +519,7 @@
 
   AnonTypedRegion* getAnonTypedRegion(QualType t, const MemRegion* superRegion);
 
-  AnonPointeeRegion* getAnonPointeeRegion(const VarDecl* d);
+  AnonPointeeRegion* getAnonPointeeRegion(const TypedRegion* r);
 
   bool hasStackStorage(const MemRegion* R);
 

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

==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Wed Dec 10 20:27:34 2008
@@ -52,7 +52,7 @@
 }
 
 QualType AnonPointeeRegion::getType(ASTContext& C) const {
-  QualType T = C.getCanonicalType(Pointer->getType());
+  QualType T = C.getCanonicalType(Pointer->getType(C));
   PointerType* PTy = cast<PointerType>(T.getTypePtr());
 
   QualType PointeeTy = C.getCanonicalType(PTy->getPointeeType());
@@ -60,10 +60,10 @@
 }
 
 void AnonPointeeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, 
-                                      const VarDecl* VD,
+                                      const TypedRegion* R,
                                       const MemRegion* superRegion) {
   ID.AddInteger((unsigned) AnonPointeeRegionKind);
-  ID.AddPointer(VD);
+  ID.AddPointer(R);
   ID.AddPointer(superRegion);
 }
 
@@ -394,11 +394,11 @@
   return R;
 }
 
-AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
+AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const TypedRegion* r) {
   llvm::FoldingSetNodeID ID;
   MemRegion* superRegion = getUnknownRegion();
 
-  AnonPointeeRegion::ProfileRegion(ID, d, superRegion);
+  AnonPointeeRegion::ProfileRegion(ID, r, superRegion);
 
   void* InsertPos;
   MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
@@ -406,7 +406,7 @@
 
   if (!R) {
     R = (AnonPointeeRegion*) A.Allocate<AnonPointeeRegion>();
-    new (R) AnonPointeeRegion(d, superRegion);
+    new (R) AnonPointeeRegion(r, superRegion);
     Regions.InsertNode(R, InsertPos);
   }
 





More information about the cfe-commits mailing list