diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-10-03 01:08:28 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-10-03 01:08:28 +0000 |
commit | 041ce8e00afd1185549a25d5c2b97d219ae032d9 (patch) | |
tree | 2822099dd1b8e0266c4aa27d3ca543290fa1022c /lib/StaticAnalyzer/Core/RegionStore.cpp | |
parent | 6b2cc42f1504db6577fd67fa55ef023254744e2c (diff) |
Teach getCXXRecordDeclForPointerType about references.
Then, rename it getPointeeCXXRecordDecl and give it a nice doc comment,
and actually use it.
No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/RegionStore.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/RegionStore.cpp | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index aadb963e50..4902f246ec 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -900,31 +900,16 @@ SVal RegionStoreManager::ArrayToPointer(Loc Array) { return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx, ArrayR, Ctx)); } -// This mirrors Type::getCXXRecordDeclForPointerType(), but there doesn't -// appear to be another need for this in the rest of the codebase. -static const CXXRecordDecl *GetCXXRecordDeclForReferenceType(QualType Ty) { - if (const ReferenceType *RT = Ty->getAs<ReferenceType>()) - if (const RecordType *RCT = RT->getPointeeType()->getAs<RecordType>()) - return dyn_cast<CXXRecordDecl>(RCT->getDecl()); - return 0; -} - SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType baseType) { - const CXXRecordDecl *baseDecl; - - if (baseType->isPointerType()) - baseDecl = baseType->getCXXRecordDeclForPointerType(); - else if (baseType->isReferenceType()) - baseDecl = GetCXXRecordDeclForReferenceType(baseType); - else - baseDecl = baseType->getAsCXXRecordDecl(); - - assert(baseDecl && "not a CXXRecordDecl?"); - loc::MemRegionVal *derivedRegVal = dyn_cast<loc::MemRegionVal>(&derived); if (!derivedRegVal) return derived; + const CXXRecordDecl *baseDecl = baseType->getPointeeCXXRecordDecl(); + if (!baseDecl) + baseDecl = baseType->getAsCXXRecordDecl(); + assert(baseDecl && "not a C++ object?"); + const MemRegion *baseReg = MRMgr.getCXXBaseObjectRegion(baseDecl, derivedRegVal->getRegion()); |