]> granicus.if.org Git - clang/commitdiff
- Revert r59229 and r59232: AllocRegion should be immutable.
authorTed Kremenek <kremenek@apple.com>
Thu, 13 Nov 2008 15:42:31 +0000 (15:42 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 13 Nov 2008 15:42:31 +0000 (15:42 +0000)
- Temporarily disabled test Analysis/array-struct.c for region store.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59245 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/MemRegion.h
lib/Analysis/GRExprEngine.cpp
test/Analysis/array-struct.c

index 2de2a3ed14a8f21e813d90db87d6e1e07071c743..04d904623e2b0d9cb261ffb295041c6282cb5f3f 100644 (file)
@@ -37,9 +37,9 @@ class MemRegionManager;
 class MemRegion : public llvm::FoldingSetNode {
 public:
   enum Kind { MemSpaceRegionKind, SymbolicRegionKind,
+              AllocaRegionKind,
               // Typed regions.
               BEG_TYPED_REGIONS,
-               AllocaRegionKind,
                CompoundLiteralRegionKind,
                StringRegionKind, ElementRegionKind,
                // Decl Regions.
@@ -102,6 +102,34 @@ public:
   }
 };
   
+/// AllocaRegion - A region that represents an untyped blob of bytes created
+///  by a call to 'alloca'.
+class AllocaRegion : public SubRegion {
+  friend class MemRegionManager;
+protected:
+  unsigned Cnt; // Block counter.  Used to distinguish different pieces of
+                // memory allocated by alloca at the same call site.
+  const Expr* Ex;
+
+  AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion* superRegion)
+    : SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {}
+  
+public:
+  
+  const Expr* getExpr() const { return Ex; }
+  
+  void Profile(llvm::FoldingSetNodeID& ID) const;
+
+  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex,
+                            unsigned Cnt);
+  
+  void print(llvm::raw_ostream& os) const;
+  
+  static bool classof(const MemRegion* R) {
+    return R->getKind() == AllocaRegionKind;
+  }
+};    
+  
 /// SymbolicRegion - A special, "non-concrete" region. Unlike other region
 ///  clases, SymbolicRegion represents a region that serves as an alias for
 ///  either a real region, a NULL pointer, etc.  It essentially is used to
@@ -142,42 +170,6 @@ public:
   }
 };
 
-/// AllocaRegion - A region that represents an untyped blob of bytes created
-///  by a call to 'alloca'.
-class AllocaRegion : public TypedRegion {
-  friend class MemRegionManager;
-protected:
-  unsigned Cnt; // Block counter.  Used to distinguish different pieces of
-                // memory allocated by alloca at the same call site.
-  const Expr* Ex;
-
-  QualType T;
-
-  AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion* superRegion)
-    : TypedRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {}
-  
-public:
-  
-  const Expr* getExpr() const { return Ex; }
-
-  void setType(QualType t) { T = t; }
-
-  QualType getType(ASTContext& C) const {
-    return C.getCanonicalType(T);
-  }
-
-  void Profile(llvm::FoldingSetNodeID& ID) const;
-
-  static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex,
-                            unsigned Cnt);
-  
-  void print(llvm::raw_ostream& os) const;
-  
-  static bool classof(const MemRegion* R) {
-    return R->getKind() == AllocaRegionKind;
-  }
-};    
-
 /// StringRegion - Region associated with a StringLiteral.
 class StringRegion : public TypedRegion {
   friend class MemRegionManager;
index 76e356be4d3dec5418b6a5dac76df8246be510b3..38eeaddcb84f60acfd1a69b7dc23aa5684055bbe 100644 (file)
@@ -1681,26 +1681,6 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
       continue;
     }
 
-    // Cast alloca'ed pointer to typed pointer.
-    if (isa<loc::MemRegionVal>(V)) {
-      if (const AllocaRegion* AR = 
-          dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(V).getRegion())) {
-
-        // Set the AllocaRegion's type.
-        const_cast<AllocaRegion*>(AR)->setType(T);
-
-        // Set the CastExpr's value to a pointer to the first element.
-        MemRegionManager& RM = getStateManager().getRegionManager();
-
-        llvm::APSInt Zero(llvm::APInt::getNullValue(32), false);
-        SVal ZeroIdx(nonloc::ConcreteInt(getBasicVals().getValue(Zero)));
-        const ElementRegion* ER = RM.getElementRegion(ZeroIdx, AR);
-
-        MakeNode(Dst, CastE, N, BindExpr(St, CastE, loc::MemRegionVal(ER)));
-        continue;
-      }
-    }
-
     // All other cases.
     MakeNode(Dst, CastE, N, BindExpr(St, CastE, EvalCast(V, CastE->getType())));
   }
index 9548fa0d0e1c441b1f22163e260030f4d9e897f0..6467998ac6b492cf453e8f3f709887fbd1447884 100644 (file)
@@ -1,5 +1,5 @@
-// RUN: clang -checker-simple -verify %s &&
-// RUN: clang -checker-simple -analyzer-store-region -verify %s
+// RUN: clang -checker-simple -verify %s
+// DISABLED: clang -checker-simple -analyzer-store-region -verify %s
 
 struct s {
   int data;