[cfe-commits] r58086 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/RegionStore.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Fri Oct 24 02:06:51 PDT 2008
Author: zhongxingxu
Date: Fri Oct 24 04:06:51 2008
New Revision: 58086
URL: http://llvm.org/viewvc/llvm-project?rev=58086&view=rev
Log:
The Decl of an array region can be VarDecl or FieldDecl. Handle this in RegionStoreManager::ArrayToPointer().
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
cfe/trunk/lib/Analysis/RegionStore.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=58086&r1=58085&r2=58086&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Fri Oct 24 04:06:51 2008
@@ -192,7 +192,8 @@
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;
};
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=58086&r1=58085&r2=58086&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Fri Oct 24 04:06:51 2008
@@ -181,10 +181,18 @@
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();
More information about the cfe-commits
mailing list