diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-12-22 08:12:57 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-12-22 08:12:57 +0000 |
commit | eee1df1e7ac74bbccd5282f0348381af70cf5e5e (patch) | |
tree | bf4869842a29eb4e4700177517d127d5d02aa0de /lib/Checker/RegionStore.cpp | |
parent | a8d835abb81eb26850fa27738df0e42f12fae66a (diff) |
The base type is not always pointer type. We may cast to a base reference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/RegionStore.cpp')
-rw-r--r-- | lib/Checker/RegionStore.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index bc28f137c4..b6f992995b 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -807,9 +807,15 @@ SVal RegionStoreManager::ArrayToPointer(Loc Array) { return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx, ArrayR, Ctx)); } -SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType basePtrType) { - const CXXRecordDecl *baseDecl = basePtrType->getCXXRecordDeclForPointerType(); +SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType baseType) { + const CXXRecordDecl *baseDecl; + if (baseType->isPointerType()) + baseDecl = baseType->getCXXRecordDeclForPointerType(); + else + baseDecl = baseType->getAsCXXRecordDecl(); + assert(baseDecl && "not a CXXRecordDecl?"); + loc::MemRegionVal &derivedRegVal = cast<loc::MemRegionVal>(derived); const MemRegion *baseReg = MRMgr.getCXXBaseObjectRegion(baseDecl, derivedRegVal.getRegion()); |