[cfe-commits] r58245 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/MemRegion.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Oct 27 06:17:04 PDT 2008
Author: zhongxingxu
Date: Mon Oct 27 08:17:02 2008
New Revision: 58245
URL: http://llvm.org/viewvc/llvm-project?rev=58245&view=rev
Log:
An ElementRegion is really a typed region. Its super region's type has to be ArrayType.
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=58245&r1=58244&r2=58245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Mon Oct 27 08:17:02 2008
@@ -327,13 +327,13 @@
}
};
-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 @@
SVal getIndex() const { return Index; }
+ QualType getType(ASTContext&) const;
+
void print(llvm::raw_ostream& os) const;
void Profile(llvm::FoldingSetNodeID& ID) const;
Modified: cfe/trunk/lib/Analysis/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/MemRegion.cpp?rev=58245&r1=58244&r2=58245&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Mon Oct 27 08:17:02 2008
@@ -83,6 +83,13 @@
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.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list