diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-20 09:00:16 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-20 09:00:16 +0000 |
commit | 262fd03ee934bebfbbfaabc14744427dd2e7a231 (patch) | |
tree | 42b225e62f5e99d4cb9235f435dec96a4a36981e /lib/Analysis/RegionStore.cpp | |
parent | 5df0d426026b3820b5f0b13a8d4e60e9373d8d9d (diff) |
* API change: we need to pass GRState to GRExprEngine::EvalBinOp() because
RegionStore needs to know the type of alloca region.
* RegionStoreManager::EvalBinOp() now converts the alloca region to its first
element region, as what is done to symbolic region.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index e1d875b8f9..be34bd57b8 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -214,7 +214,7 @@ public: CastResult CastRegion(const GRState* state, const MemRegion* R, QualType CastToTy); - SVal EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R); + SVal EvalBinOp(const GRState *state,BinaryOperator::Opcode Op,Loc L,NonLoc R); /// The high level logic for this method is this: /// Retrieve (L) @@ -636,15 +636,17 @@ RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R, return 0; } -SVal RegionStoreManager::EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R) { +SVal RegionStoreManager::EvalBinOp(const GRState *state, + BinaryOperator::Opcode Op, Loc L, NonLoc R) { // Assume the base location is MemRegionVal. if (!isa<loc::MemRegionVal>(L)) return UnknownVal(); const MemRegion* MR = cast<loc::MemRegionVal>(L).getRegion(); const ElementRegion *ER = 0; - // If the operand is a symbolic region, we convert it to the first element - // region implicitly. + + // If the operand is a symbolic or alloca region, create the first element + // region on it. if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR)) { // Get symbol's type. It should be a pointer type. SymbolRef Sym = SR->getSymbol(); @@ -653,7 +655,18 @@ SVal RegionStoreManager::EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R) { SVal ZeroIdx = ValMgr.makeZeroArrayIndex(); ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR); - } else + } + else if (const AllocaRegion *AR = dyn_cast<AllocaRegion>(MR)) { + // Get the alloca region's current cast type. + GRStateRef StRef(state, StateMgr); + + GRStateTrait<RegionCasts>::lookup_type T = StRef.get<RegionCasts>(AR); + assert(T && "alloca region has no type."); + QualType EleTy = cast<PointerType>(T->getTypePtr())->getPointeeType(); + SVal ZeroIdx = ValMgr.makeZeroArrayIndex(); + ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR); + } + else ER = cast<ElementRegion>(MR); SVal Idx = ER->getIndex(); |