]> granicus.if.org Git - clang/commitdiff
An ElementRegion is really a typed region. Its super region's type has to be ArrayType.
authorZhongxing Xu <xuzhongxing@gmail.com>
Mon, 27 Oct 2008 13:17:02 +0000 (13:17 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Mon, 27 Oct 2008 13:17:02 +0000 (13:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58245 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/MemRegion.h
lib/Analysis/MemRegion.cpp

index 2a20b6320ebd28af29217b71dde3be7837e6efad..5142427b459e6da8a5916fcd4753601e9a12877d 100644 (file)
@@ -327,13 +327,13 @@ public:
   }
 };
 
-class ElementRegion : public SubRegion {
+class ElementRegion : public TypedRegion {
   friend class MemRegionManager;
 
   SVal Index;
 
   ElementRegion(SVal Idx, const MemRegion* sReg)
-    : SubRegion(sReg, ElementRegionKind), Index(Idx) {}
+    : TypedRegion(sReg, ElementRegionKind), Index(Idx) {}
 
   static void ProfileRegion(llvm::FoldingSetNodeID& ID, SVal Idx, 
                             const MemRegion* superRegion);
@@ -342,6 +342,8 @@ public:
 
   SVal getIndex() const { return Index; }
 
+  QualType getType(ASTContext&) const;
+
   void print(llvm::raw_ostream& os) const;
 
   void Profile(llvm::FoldingSetNodeID& ID) const;
index f14e0cba447c3a9cc497a4248ca0ae8d380964cb..1db330cf09665aa6542e4e391be84374161e1653 100644 (file)
@@ -83,6 +83,13 @@ void ElementRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, SVal Idx,
 void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const {
   ElementRegion::ProfileRegion(ID, Index, superRegion);
 }
+
+QualType ElementRegion::getType(ASTContext& C) const {
+  QualType T = cast<TypedRegion>(superRegion)->getType(C);
+  ArrayType* AT = cast<ArrayType>(T.getTypePtr());
+  return AT->getElementType();
+}
+
 //===----------------------------------------------------------------------===//
 // Region pretty-printing.
 //===----------------------------------------------------------------------===//