diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-10-24 09:06:51 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-10-24 09:06:51 +0000 |
commit | bfb6582ef46dfb33672d9621f879fc262339d704 (patch) | |
tree | 0e5ec087f327ccef3824878d3e7f55393c4da8a9 | |
parent | 72e1682bbdfd497ce838d648bb2cb6047c015f6f (diff) |
The Decl of an array region can be VarDecl or FieldDecl. Handle this in RegionStoreManager::ArrayToPointer().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58086 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/PathSensitive/MemRegion.h | 3 | ||||
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h index a78059dfed..e0ecb7180f 100644 --- a/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/include/clang/Analysis/PathSensitive/MemRegion.h @@ -192,7 +192,8 @@ protected: static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Decl* D, const MemRegion* superRegion, Kind k); -public: +public: + const Decl* getDecl() const { return D; } void Profile(llvm::FoldingSetNodeID& ID) const; }; diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index bd3dd0911d..5c75ab369e 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -181,10 +181,18 @@ SVal RegionStoreManager::getLValueElement(const GRState* St, SVal RegionStoreManager::ArrayToPointer(SVal Array) { const MemRegion* ArrayR = cast<loc::MemRegionVal>(&Array)->getRegion(); - const VarDecl* D = cast<VarRegion>(ArrayR)->getDecl(); + const Decl* D = cast<DeclRegion>(ArrayR)->getDecl(); + + QualType ArrayTy; + if (const VarDecl* VD = dyn_cast<VarDecl>(D)) + ArrayTy = VD->getType(); + else if (const FieldDecl* FD = dyn_cast<FieldDecl>(D)) + ArrayTy = FD->getType(); + else + assert(0 && "unknown decl"); if (const ConstantArrayType* CAT = - dyn_cast<ConstantArrayType>(D->getType().getTypePtr())) { + dyn_cast<ConstantArrayType>(ArrayTy.getTypePtr())) { BasicValueFactory& BasicVals = StateMgr.getBasicVals(); |