summaryrefslogtreecommitdiffstats
path: root/clang/lib/Checker/MemRegion.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-11-26 08:21:53 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-11-26 08:21:53 +0000
commitec0b8e32eec37c4713f865373a812749ede815a6 (patch)
treefa071b1209d5a32a45041cb45d94433473535179 /clang/lib/Checker/MemRegion.cpp
parente23ab6fae29ab8f301fb529d6b7e4dd40c45b4e5 (diff)
downloadbcm5719-llvm-ec0b8e32eec37c4713f865373a812749ede815a6.tar.gz
bcm5719-llvm-ec0b8e32eec37c4713f865373a812749ede815a6.zip
Regionstore: support derived-to-base cast by creating a CXXBaseObjectRegion.
llvm-svn: 120173
Diffstat (limited to 'clang/lib/Checker/MemRegion.cpp')
-rw-r--r--clang/lib/Checker/MemRegion.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/Checker/MemRegion.cpp b/clang/lib/Checker/MemRegion.cpp
index 4414c1a57a6..366a5746837 100644
--- a/clang/lib/Checker/MemRegion.cpp
+++ b/clang/lib/Checker/MemRegion.cpp
@@ -218,6 +218,10 @@ DefinedOrUnknownSVal StringRegion::getExtent(ValueManager& ValMgr) const {
return ValMgr.makeIntVal(getStringLiteral()->getByteLength()+1, SizeTy);
}
+QualType CXXBaseObjectRegion::getValueType() const {
+ return QualType(decl->getTypeForDecl(), 0);
+}
+
//===----------------------------------------------------------------------===//
// FoldingSet profiling.
//===----------------------------------------------------------------------===//
@@ -367,6 +371,17 @@ void CXXObjectRegion::Profile(llvm::FoldingSetNodeID &ID) const {
ProfileRegion(ID, Ex, getSuperRegion());
}
+void CXXBaseObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
+ const CXXRecordDecl *decl,
+ const MemRegion *sReg) {
+ ID.AddPointer(decl);
+ ID.AddPointer(sReg);
+}
+
+void CXXBaseObjectRegion::Profile(llvm::FoldingSetNodeID &ID) const {
+ ProfileRegion(ID, decl, superRegion);
+}
+
//===----------------------------------------------------------------------===//
// Region pretty-printing.
//===----------------------------------------------------------------------===//
@@ -411,6 +426,10 @@ void CXXObjectRegion::dumpToStream(llvm::raw_ostream &os) const {
os << "temp_object";
}
+void CXXBaseObjectRegion::dumpToStream(llvm::raw_ostream &os) const {
+ os << "base " << decl->getName();
+}
+
void CXXThisRegion::dumpToStream(llvm::raw_ostream &os) const {
os << "this";
}
@@ -687,6 +706,12 @@ MemRegionManager::getCXXObjectRegion(Expr const *E,
return getSubRegion<CXXObjectRegion>(E, getStackLocalsRegion(SFC));
}
+const CXXBaseObjectRegion *
+MemRegionManager::getCXXBaseObjectRegion(const CXXRecordDecl *decl,
+ const MemRegion *superRegion) {
+ return getSubRegion<CXXBaseObjectRegion>(decl, superRegion);
+}
+
const CXXThisRegion*
MemRegionManager::getCXXThisRegion(QualType thisPointerTy,
const LocationContext *LC) {
OpenPOWER on IntegriCloud