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 | e834fc12499fa4f04078a88be4029a0e6cdc7296 (patch) | |
| tree | 9284b9fe13b98519b9a96b3b3f9c46b5b85fa8f3 | |
| parent | d2f0c7b37b3fe8397f86fc20ec68fbf6c9463e27 (diff) | |
| download | bcm5719-llvm-e834fc12499fa4f04078a88be4029a0e6cdc7296.tar.gz bcm5719-llvm-e834fc12499fa4f04078a88be4029a0e6cdc7296.zip | |
The Decl of an array region can be VarDecl or FieldDecl. Handle this in RegionStoreManager::ArrayToPointer().
llvm-svn: 58086
| -rw-r--r-- | clang/include/clang/Analysis/PathSensitive/MemRegion.h | 3 | ||||
| -rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/include/clang/Analysis/PathSensitive/MemRegion.h b/clang/include/clang/Analysis/PathSensitive/MemRegion.h index a78059dfedb..e0ecb7180fc 100644 --- a/clang/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/clang/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/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index bd3dd0911dd..5c75ab369ec 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/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(); |

