diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-09 13:20:07 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-09 13:20:07 +0000 |
commit | ce7607858fae388a04c8b727c18f3da9a577dd2f (patch) | |
tree | b8ab6d7d3c486ec4f4bc13177671f0c1e70b010c /lib/Analysis/RegionStore.cpp | |
parent | db3a098c23865ee00b14379b49eb516212c19388 (diff) |
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
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 22 |
1 files 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<nonloc::ConcreteInt>(Offset)) return UnknownVal(); - const TypedRegion* BaseRegion = 0; - - const MemRegion* R = cast<loc::MemRegionVal>(Base).getRegion(); - if (const SymbolicRegion* SR = dyn_cast<SymbolicRegion>(R)) { - SymbolRef Sym = SR->getSymbol(); - BaseRegion = MRMgr.getTypedViewRegion(Sym->getType(getContext()), SR); - } - else - BaseRegion = cast<TypedRegion>(R); + const MemRegion* BaseRegion = cast<loc::MemRegionVal>(Base).getRegion(); // Pointer of any type can be cast and used as array base. const ElementRegion *ElemR = dyn_cast<ElementRegion>(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<AllocaRegion>. + // 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<TypedRegion>(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<AllocaRegion>(R)) { + return UnknownVal(); + } + if (isa<ElementRegion>(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<SymbolicRegion>(R) || isa<AllocaRegion>(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 |