From 7b700575dde6c4973a2fbb98b02ffebcd8a42e45 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Mon, 27 Oct 2008 13:17:02 +0000 Subject: [PATCH] An ElementRegion is really a typed region. Its super region's type has to be ArrayType. llvm-svn: 58245 --- clang/include/clang/Analysis/PathSensitive/MemRegion.h | 6 ++++-- clang/lib/Analysis/MemRegion.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Analysis/PathSensitive/MemRegion.h b/clang/include/clang/Analysis/PathSensitive/MemRegion.h index 2a20b6320ebd..5142427b459e 100644 --- a/clang/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/clang/include/clang/Analysis/PathSensitive/MemRegion.h @@ -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; diff --git a/clang/lib/Analysis/MemRegion.cpp b/clang/lib/Analysis/MemRegion.cpp index f14e0cba447c..1db330cf0966 100644 --- a/clang/lib/Analysis/MemRegion.cpp +++ b/clang/lib/Analysis/MemRegion.cpp @@ -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(superRegion)->getType(C); + ArrayType* AT = cast(T.getTypePtr()); + return AT->getElementType(); +} + //===----------------------------------------------------------------------===// // Region pretty-printing. //===----------------------------------------------------------------------===//