aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-10-27 13:17:02 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-10-27 13:17:02 +0000
commit27b57063d83b00474d7563fb5d608544e2364862 (patch)
tree594de8317f46f585f268e8ab88e137150600551c
parent3dda64ec0fad2fa60d882565d135ff598897fa9d (diff)
An ElementRegion is really a typed region. Its super region's type has to be ArrayType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58245 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Analysis/PathSensitive/MemRegion.h6
-rw-r--r--lib/Analysis/MemRegion.cpp7
2 files changed, 11 insertions, 2 deletions
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h
index 2a20b6320e..5142427b45 100644
--- a/include/clang/Analysis/PathSensitive/MemRegion.h
+++ b/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/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index f14e0cba44..1db330cf09 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/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<TypedRegion>(superRegion)->getType(C);
+ ArrayType* AT = cast<ArrayType>(T.getTypePtr());
+ return AT->getElementType();
+}
+
//===----------------------------------------------------------------------===//
// Region pretty-printing.
//===----------------------------------------------------------------------===//