From: Zhongxing Xu Date: Fri, 24 Oct 2008 09:06:51 +0000 (+0000) Subject: The Decl of an array region can be VarDecl or FieldDecl. Handle this in RegionStoreMa... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfb6582ef46dfb33672d9621f879fc262339d704;p=clang 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 --- 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(&Array)->getRegion(); - const VarDecl* D = cast(ArrayR)->getDecl(); + const Decl* D = cast(ArrayR)->getDecl(); + + QualType ArrayTy; + if (const VarDecl* VD = dyn_cast(D)) + ArrayTy = VD->getType(); + else if (const FieldDecl* FD = dyn_cast(D)) + ArrayTy = FD->getType(); + else + assert(0 && "unknown decl"); if (const ConstantArrayType* CAT = - dyn_cast(D->getType().getTypePtr())) { + dyn_cast(ArrayTy.getTypePtr())) { BasicValueFactory& BasicVals = StateMgr.getBasicVals();