From ce7607858fae388a04c8b727c18f3da9a577dd2f Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Sat, 9 May 2009 13:20:07 +0000 Subject: [PATCH] Do not layer a TypedViewRegion when casting symbolic or alloca regions. Modify getLValueElement accordingly. Now we don't require base region to be a typed region. Do not create TypedViewRegion when base region is symbolic or alloca region. We can do so because each element region has its type information. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71355 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/RegionStore.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 4528ffbd2d..354ad5c57a 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -416,15 +416,7 @@ SVal RegionStoreManager::getLValueElement(const GRState* St, if (!isa(Offset)) return UnknownVal(); - const TypedRegion* BaseRegion = 0; - - const MemRegion* R = cast(Base).getRegion(); - if (const SymbolicRegion* SR = dyn_cast(R)) { - SymbolRef Sym = SR->getSymbol(); - BaseRegion = MRMgr.getTypedViewRegion(Sym->getType(getContext()), SR); - } - else - BaseRegion = cast(R); + const MemRegion* BaseRegion = cast(Base).getRegion(); // Pointer of any type can be cast and used as array base. const ElementRegion *ElemR = dyn_cast(BaseRegion); @@ -437,7 +429,7 @@ SVal RegionStoreManager::getLValueElement(const GRState* St, // char *p = __builtin_alloc(10); // p[1] = 8; // - // Observe that 'p' binds to an TypedViewRegion. + // Observe that 'p' binds to an AllocaRegion. // // Offset might be unsigned. We have to convert it to signed ConcreteInt. @@ -467,7 +459,7 @@ SVal RegionStoreManager::getLValueElement(const GRState* St, // can't we need to put a comment here. If it can, we should handle it. assert(BaseIdxI.getBitWidth() >= OffI.getBitWidth()); - const TypedRegion *ArrayR = cast(ElemR->getSuperRegion()); + const MemRegion *ArrayR = ElemR->getSuperRegion(); SVal NewIdx; if (OffI.isUnsigned() || OffI.getBitWidth() < BaseIdxI.getBitWidth()) { @@ -581,6 +573,10 @@ SVal RegionStoreManager::getSizeInElements(const GRState* St, return UnknownVal(); } + if (isa(R)) { + return UnknownVal(); + } + if (isa(R)) { return UnknownVal(); } @@ -650,8 +646,8 @@ RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R, // to be re-used for a different purpose. if (isa(R) || isa(R)) { - const MemRegion* ViewR = MRMgr.getTypedViewRegion(CastToTy, R); - return CastResult(AddRegionView(state, ViewR, R), ViewR); + state = setCastType(state, R, ToTy); + return CastResult(state, R); } // VarRegion, ElementRegion, and FieldRegion has an inherent type. Normally -- 2.40.0