From: Ted Kremenek Date: Fri, 21 Aug 2009 22:28:32 +0000 (+0000) Subject: Add LocationContext* field to VarRegion. This is needed for interprocedural analysis. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d17da2b99f323fa91b01e1dd119cc32e0ee8197d;p=clang Add LocationContext* field to VarRegion. This is needed for interprocedural analysis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79680 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 66cb2d209a..5ab4dceed7 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -206,7 +206,7 @@ public: // Utility methods for getting regions. //==---------------------------------------------------------------------==// - const VarRegion* getRegion(const VarDecl* D) const; + const VarRegion* getRegion(const VarDecl *D, const LocationContext *LC) const; const MemRegion* getSelfRegion() const; @@ -230,9 +230,11 @@ public: return bindExpr(Ex, V, true, false); } - const GRState *bindDecl(const VarDecl* VD, SVal IVal) const; + const GRState *bindDecl(const VarDecl *VD, const LocationContext *LC, + SVal V) const; - const GRState *bindDeclWithNoInit(const VarDecl* VD) const; + const GRState *bindDeclWithNoInit(const VarDecl *VD, + const LocationContext *LC) const; const GRState *bindLoc(Loc location, SVal V) const; @@ -241,7 +243,7 @@ public: const GRState *unbindLoc(Loc LV) const; /// Get the lvalue for a variable reference. - SVal getLValue(const VarDecl *decl) const; + SVal getLValue(const VarDecl *D, const LocationContext *LC) const; /// Get the lvalue for a StringLiteral. SVal getLValue(const StringLiteral *literal) const; @@ -599,8 +601,9 @@ public: // Out-of-line method definitions for GRState. //===----------------------------------------------------------------------===// -inline const VarRegion* GRState::getRegion(const VarDecl* D) const { - return Mgr->getRegionManager().getVarRegion(D); +inline const VarRegion* GRState::getRegion(const VarDecl *D, + const LocationContext *LC) const { + return Mgr->getRegionManager().getVarRegion(D, LC); } inline const MemRegion* GRState::getSelfRegion() const { @@ -621,12 +624,15 @@ inline const GRState *GRState::bindCompoundLiteral(const CompoundLiteralExpr* CL return Mgr->StoreMgr->BindCompoundLiteral(this, CL, V); } -inline const GRState *GRState::bindDecl(const VarDecl* VD, SVal IVal) const { - return Mgr->StoreMgr->BindDecl(this, VD, IVal); +inline const GRState *GRState::bindDecl(const VarDecl* VD, + const LocationContext *LC, + SVal IVal) const { + return Mgr->StoreMgr->BindDecl(this, VD, LC, IVal); } -inline const GRState *GRState::bindDeclWithNoInit(const VarDecl* VD) const { - return Mgr->StoreMgr->BindDeclWithNoInit(this, VD); +inline const GRState *GRState::bindDeclWithNoInit(const VarDecl* VD, + const LocationContext *LC) const { + return Mgr->StoreMgr->BindDeclWithNoInit(this, VD, LC); } inline const GRState *GRState::bindLoc(Loc LV, SVal V) const { @@ -637,8 +643,9 @@ inline const GRState *GRState::bindLoc(SVal LV, SVal V) const { return !isa(LV) ? this : bindLoc(cast(LV), V); } -inline SVal GRState::getLValue(const VarDecl* VD) const { - return Mgr->StoreMgr->getLValueVar(this, VD); +inline SVal GRState::getLValue(const VarDecl* VD, + const LocationContext *LC) const { + return Mgr->StoreMgr->getLValueVar(this, VD, LC); } inline SVal GRState::getLValue(const StringLiteral *literal) const { diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h index cfa9498d7d..bc47c8a1a5 100644 --- a/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/include/clang/Analysis/PathSensitive/MemRegion.h @@ -33,7 +33,8 @@ namespace llvm { class raw_ostream; } namespace clang { class MemRegionManager; -class MemSpaceRegion; +class MemSpaceRegion; +class LocationContext; //===----------------------------------------------------------------------===// // Base region classes. @@ -423,17 +424,27 @@ public: class VarRegion : public DeclRegion { friend class MemRegionManager; + + // Data. + const LocationContext *LC; - VarRegion(const VarDecl* vd, const MemRegion* sReg) - : DeclRegion(vd, sReg, VarRegionKind) {} + // Constructors and private methods. + VarRegion(const VarDecl* vd, const LocationContext *lC, const MemRegion* sReg) + : DeclRegion(vd, sReg, VarRegionKind), LC(lC) {} static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* VD, - const MemRegion* superRegion) { + const LocationContext *LC, + const MemRegion *superRegion) { DeclRegion::ProfileRegion(ID, VD, superRegion, VarRegionKind); + ID.AddPointer(LC); } + void Profile(llvm::FoldingSetNodeID& ID) const; + public: - const VarDecl* getDecl() const { return cast(D); } + const VarDecl *getDecl() const { return cast(D); } + + const LocationContext *getLocationContext() const { return LC; } QualType getValueType(ASTContext& C) const { // FIXME: We can cache this if needed. @@ -633,13 +644,14 @@ public: StringRegion* getStringRegion(const StringLiteral* Str); /// getVarRegion - Retrieve or create the memory region associated with - /// a specified VarDecl. - VarRegion* getVarRegion(const VarDecl* vd); + /// a specified VarDecl and LocationContext. + VarRegion* getVarRegion(const VarDecl *D, const LocationContext *LC); /// getElementRegion - Retrieve the memory region associated with the /// associated element type, index, and super region. ElementRegion *getElementRegion(QualType elementType, SVal Idx, - const MemRegion* superRegion,ASTContext &Ctx); + const MemRegion *superRegion, + ASTContext &Ctx); ElementRegion *getElementRegionWithSuper(const ElementRegion *ER, const MemRegion *superRegion) { @@ -794,10 +806,14 @@ template <> struct MemRegionManagerTrait { template <> struct MemRegionManagerTrait { typedef MemRegion SuperRegionTy; - static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, - const VarDecl *d) { - if (d->hasLocalStorage()) { - return isa(d) || isa(d) + static const SuperRegionTy* getSuperRegion(MemRegionManager &MRMgr, + const VarDecl *D, + const LocationContext *LC) { + + // FIXME: Make stack regions have a location context? + + if (D->hasLocalStorage()) { + return isa(D) || isa(D) ? MRMgr.getStackArgumentsRegion() : MRMgr.getStackRegion(); } diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h index a9fbcc55d5..df56963e48 100644 --- a/include/clang/Analysis/PathSensitive/Store.h +++ b/include/clang/Analysis/PathSensitive/Store.h @@ -88,7 +88,8 @@ public: // caller's responsibility to 'delete' the returned map. virtual SubRegionMap *getSubRegionMap(const GRState *state) = 0; - virtual SVal getLValueVar(const GRState *state, const VarDecl *vd) = 0; + virtual SVal getLValueVar(const GRState *ST, const VarDecl *VD, + const LocationContext *LC) = 0; virtual SVal getLValueString(const GRState *state, const StringLiteral* sl) = 0; @@ -144,11 +145,12 @@ public: SymbolReaper& SymReaper, llvm::SmallVectorImpl& RegionRoots) = 0; - virtual const GRState *BindDecl(const GRState *state, const VarDecl *vd, - SVal initVal) = 0; + virtual const GRState *BindDecl(const GRState *ST, const VarDecl *VD, + const LocationContext *LC, SVal initVal) = 0; - virtual const GRState *BindDeclWithNoInit(const GRState *state, - const VarDecl *vd) = 0; + virtual const GRState *BindDeclWithNoInit(const GRState *ST, + const VarDecl *VD, + const LocationContext *LC) = 0; virtual const GRState *InvalidateRegion(const GRState *state, const MemRegion *R, diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index f6d3d35f74..65efb66148 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -65,8 +65,8 @@ public: Store getInitialStore(const LocationContext *InitLoc); // FIXME: Investigate what is using this. This method should be removed. - virtual Loc getLoc(const VarDecl* VD) { - return ValMgr.makeLoc(MRMgr.getVarRegion(VD)); + virtual Loc getLoc(const VarDecl* VD, const LocationContext *LC) { + return ValMgr.makeLoc(MRMgr.getVarRegion(VD, LC)); } const GRState *BindCompoundLiteral(const GRState *state, @@ -75,12 +75,13 @@ public: return state; } - SVal getLValueVar(const GRState *state, const VarDecl* VD); - SVal getLValueString(const GRState *state, const StringLiteral* S); + SVal getLValueVar(const GRState *state, const VarDecl *VD, + const LocationContext *LC); + SVal getLValueString(const GRState *state, const StringLiteral *S); SVal getLValueCompoundLiteral(const GRState *state, - const CompoundLiteralExpr* CL); + const CompoundLiteralExpr *CL); SVal getLValueIvar(const GRState *state, const ObjCIvarDecl* D, SVal Base); - SVal getLValueField(const GRState *state, SVal Base, const FieldDecl* D); + SVal getLValueField(const GRState *state, SVal Base, const FieldDecl *D); SVal getLValueElement(const GRState *state, QualType elementType, SVal Base, SVal Offset); @@ -100,15 +101,19 @@ public: void iterBindings(Store store, BindingsHandler& f); - const GRState *BindDecl(const GRState *state, const VarDecl* VD, SVal InitVal) { - return state->makeWithStore(BindDeclInternal(state->getStore(),VD, &InitVal)); + const GRState *BindDecl(const GRState *state, const VarDecl *VD, + const LocationContext *LC, SVal InitVal) { + return state->makeWithStore(BindDeclInternal(state->getStore(),VD, LC, + &InitVal)); } - const GRState *BindDeclWithNoInit(const GRState *state, const VarDecl* VD) { - return state->makeWithStore(BindDeclInternal(state->getStore(), VD, 0)); + const GRState *BindDeclWithNoInit(const GRState *state, const VarDecl *VD, + const LocationContext *LC) { + return state->makeWithStore(BindDeclInternal(state->getStore(), VD, LC, 0)); } - Store BindDeclInternal(Store store, const VarDecl* VD, SVal* InitVal); + Store BindDeclInternal(Store store, const VarDecl *VD, + const LocationContext *LC, SVal *InitVal); static inline BindingsTy GetBindings(Store store) { return BindingsTy(static_cast(store)); @@ -128,8 +133,9 @@ StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) { return new BasicStoreManager(StMgr); } -SVal BasicStoreManager::getLValueVar(const GRState *state, const VarDecl* VD) { - return ValMgr.makeLoc(MRMgr.getVarRegion(VD)); +SVal BasicStoreManager::getLValueVar(const GRState *state, const VarDecl* VD, + const LocationContext *LC) { + return ValMgr.makeLoc(MRMgr.getVarRegion(VD, LC)); } SVal BasicStoreManager::getLValueString(const GRState *state, @@ -510,7 +516,7 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) { SelfRegion = MRMgr.getObjCObjectRegion(MD->getClassInterface(), MRMgr.getHeapRegion()); - St = BindInternal(St, ValMgr.makeLoc(MRMgr.getVarRegion(PD)), + St = BindInternal(St, ValMgr.makeLoc(MRMgr.getVarRegion(PD, InitLoc)), ValMgr.makeLoc(SelfRegion)); // Scan the method for ivar references. While this requires an @@ -526,7 +532,7 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) { // Initialize globals and parameters to symbolic values. // Initialize local variables to undefined. - const MemRegion *R = ValMgr.getRegionManager().getVarRegion(VD); + const MemRegion *R = ValMgr.getRegionManager().getVarRegion(VD, InitLoc); SVal X = R->hasGlobalsOrParametersStorage() ? ValMgr.getRegionValueSymbolVal(R) : UndefinedVal(); @@ -538,6 +544,7 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) { } Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD, + const LocationContext *LC, SVal* InitVal) { BasicValueFactory& BasicVals = StateMgr.getBasicVals(); @@ -568,16 +575,16 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD, if (!InitVal) { QualType T = VD->getType(); if (Loc::IsLocType(T)) - store = BindInternal(store, getLoc(VD), + store = BindInternal(store, getLoc(VD, LC), loc::ConcreteInt(BasicVals.getValue(0, T))); else if (T->isIntegerType()) - store = BindInternal(store, getLoc(VD), + store = BindInternal(store, getLoc(VD, LC), nonloc::ConcreteInt(BasicVals.getValue(0, T))); else { // assert(0 && "ignore other types of variables"); } } else { - store = BindInternal(store, getLoc(VD), *InitVal); + store = BindInternal(store, getLoc(VD, LC), *InitVal); } } } else { @@ -585,7 +592,7 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD, QualType T = VD->getType(); if (ValMgr.getSymbolManager().canSymbolicate(T)) { SVal V = InitVal ? *InitVal : UndefinedVal(); - store = BindInternal(store, getLoc(VD), V); + store = BindInternal(store, getLoc(VD, LC), V); } } diff --git a/lib/Analysis/BugReporterVisitors.cpp b/lib/Analysis/BugReporterVisitors.cpp index 604542b2c1..5c31066eff 100644 --- a/lib/Analysis/BugReporterVisitors.cpp +++ b/lib/Analysis/BugReporterVisitors.cpp @@ -314,7 +314,7 @@ void clang::bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC, if (const DeclRefExpr *DR = dyn_cast(S)) { if (const VarDecl *VD = dyn_cast(DR->getDecl())) { const VarRegion *R = - StateMgr.getRegionManager().getVarRegion(VD); + StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext()); // What did we load? SVal V = state->getSVal(S); diff --git a/lib/Analysis/CheckNSError.cpp b/lib/Analysis/CheckNSError.cpp index f152d4451d..800940dc61 100644 --- a/lib/Analysis/CheckNSError.cpp +++ b/lib/Analysis/CheckNSError.cpp @@ -42,7 +42,8 @@ class VISIBILITY_HIDDEN NSErrorCheck : public BugType { bool CheckNSErrorArgument(QualType ArgTy); bool CheckCFErrorArgument(QualType ArgTy); - void CheckParamDeref(VarDecl* V, const GRState *state, BugReporter& BR); + void CheckParamDeref(const VarDecl *V, const LocationContext *LC, + const GRState *state, BugReporter& BR); void EmitRetTyWarning(BugReporter& BR, const Decl& CodeDecl); @@ -94,8 +95,7 @@ void NSErrorCheck::FlushReports(BugReporter& BR) { // Scan the parameters for an implicit null dereference. for (llvm::SmallVectorImpl::iterator I=ErrorParams.begin(), E=ErrorParams.end(); I!=E; ++I) - CheckParamDeref(*I, (*RI)->getState(), BR); - + CheckParamDeref(*I, (*RI)->getLocationContext(), (*RI)->getState(), BR); } } @@ -191,10 +191,12 @@ bool NSErrorCheck::CheckCFErrorArgument(QualType ArgTy) { return TT->getDecl()->getIdentifier() == II; } -void NSErrorCheck::CheckParamDeref(VarDecl* Param, const GRState *rootState, +void NSErrorCheck::CheckParamDeref(const VarDecl *Param, + const LocationContext *LC, + const GRState *rootState, BugReporter& BR) { - SVal ParamL = rootState->getLValue(Param); + SVal ParamL = rootState->getLValue(Param, LC); const MemRegion* ParamR = cast(ParamL).getRegionAs(); assert (ParamR && "Parameters always have VarRegions."); SVal ParamSVal = rootState->getSVal(ParamR); diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 3f59ba6524..a8d34071e6 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -215,7 +215,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { const ParmVarDecl *PD = FD->getParamDecl(0); QualType T = PD->getType(); if (T->isIntegerType()) - if (const MemRegion *R = state->getRegion(PD)) { + if (const MemRegion *R = state->getRegion(PD, InitLoc)) { SVal V = state->getSVal(loc::MemRegionVal(R)); SVal Constraint = EvalBinOp(state, BinaryOperator::GT, V, ValMgr.makeZeroVal(T), @@ -967,8 +967,8 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred, // Transfer functions: Loads and stores. //===----------------------------------------------------------------------===// -void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, ExplodedNode* Pred, - ExplodedNodeSet& Dst, bool asLValue) { +void GRExprEngine::VisitDeclRefExpr(DeclRefExpr *Ex, ExplodedNode *Pred, + ExplodedNodeSet &Dst, bool asLValue) { const GRState* state = GetState(Pred); @@ -976,7 +976,7 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, ExplodedNode* Pred, if (const VarDecl* VD = dyn_cast(D)) { - SVal V = state->getLValue(VD); + SVal V = state->getLValue(VD, Pred->getLocationContext()); if (asLValue) MakeNode(Dst, Ex, Pred, state->bindExpr(Ex, V), @@ -1781,7 +1781,7 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, if (DeclStmt* DS = dyn_cast(elem)) { VarDecl* ElemD = cast(DS->getSingleDecl()); assert (ElemD->getInit() == 0); - ElementV = GetState(Pred)->getLValue(ElemD); + ElementV = GetState(Pred)->getLValue(ElemD, Pred->getLocationContext()); VisitObjCForCollectionStmtAux(S, Pred, Dst, ElementV); return; } @@ -2130,7 +2130,8 @@ void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL, } } -void GRExprEngine::VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeSet& Dst) { +void GRExprEngine::VisitDeclStmt(DeclStmt *DS, ExplodedNode *Pred, + ExplodedNodeSet& Dst) { // The CFG has one DeclStmt per Decl. Decl* D = *DS->decl_begin(); @@ -2188,6 +2189,8 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeS } // Decls without InitExpr are not initialized explicitly. + const LocationContext *LC = (*I)->getLocationContext(); + if (InitEx) { SVal InitVal = state->getSVal(InitEx); QualType T = VD->getType(); @@ -2199,17 +2202,17 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeS InitVal = ValMgr.getConjuredSymbolVal(InitEx, Count); } - state = state->bindDecl(VD, InitVal); + state = state->bindDecl(VD, LC, InitVal); // The next thing to do is check if the GRTransferFuncs object wants to // update the state based on the new binding. If the GRTransferFunc // object doesn't do anything, just auto-propagate the current state. GRStmtNodeBuilderRef BuilderRef(Dst, *Builder, *this, *I, state, DS,true); - getTF().EvalBind(BuilderRef, loc::MemRegionVal(state->getRegion(VD)), + getTF().EvalBind(BuilderRef, loc::MemRegionVal(state->getRegion(VD, LC)), InitVal); } else { - state = state->bindDeclWithNoInit(VD); + state = state->bindDeclWithNoInit(VD, LC); MakeNode(Dst, DS, *I, state); } } diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp index ac633060fd..2aacbf9065 100644 --- a/lib/Analysis/MemRegion.cpp +++ b/lib/Analysis/MemRegion.cpp @@ -98,6 +98,10 @@ void DeclRegion::Profile(llvm::FoldingSetNodeID& ID) const { DeclRegion::ProfileRegion(ID, D, superRegion, getKind()); } +void VarRegion::Profile(llvm::FoldingSetNodeID &ID) const { + VarRegion::ProfileRegion(ID, getDecl(), LC, superRegion); +} + void SymbolicRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym, const MemRegion *sreg) { ID.AddInteger((unsigned) MemRegion::SymbolicRegionKind); @@ -249,8 +253,9 @@ StringRegion* MemRegionManager::getStringRegion(const StringLiteral* Str) { return getRegion(Str); } -VarRegion* MemRegionManager::getVarRegion(const VarDecl* d) { - return getRegion(d); +VarRegion* MemRegionManager::getVarRegion(const VarDecl* D, + const LocationContext *LC) { + return getRegion(D, LC); } CompoundLiteralRegion* diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 518978cfb1..13768eca8c 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -204,7 +204,8 @@ public: /// getLValueVar - Returns an SVal that represents the lvalue of a /// variable. Within RegionStore a variable has an associated /// VarRegion, and the lvalue of the variable is the lvalue of that region. - SVal getLValueVar(const GRState *state, const VarDecl* VD); + SVal getLValueVar(const GRState *ST, const VarDecl *VD, + const LocationContext *LC); SVal getLValueIvar(const GRState *state, const ObjCIvarDecl* D, SVal Base); @@ -243,7 +244,7 @@ public: if (MD->getSelfDecl() == PD) { SelfRegion = MRMgr.getObjCObjectRegion(MD->getClassInterface(), MRMgr.getHeapRegion()); - B = RBFactory.Add(B, MRMgr.getVarRegion(PD), + B = RBFactory.Add(B, MRMgr.getVarRegion(PD, InitLoc), ValMgr.makeLoc(SelfRegion)); } } @@ -280,9 +281,11 @@ public: const GRState *BindCompoundLiteral(const GRState *state, const CompoundLiteralExpr* CL, SVal V); - const GRState *BindDecl(const GRState *state, const VarDecl* VD, SVal InitVal); + const GRState *BindDecl(const GRState *ST, const VarDecl *VD, + const LocationContext *LC, SVal InitVal); - const GRState *BindDeclWithNoInit(const GRState *state, const VarDecl* VD) { + const GRState *BindDeclWithNoInit(const GRState *state, const VarDecl*, + const LocationContext *) { return state; } @@ -547,8 +550,9 @@ SVal RegionStoreManager::getLValueString(const GRState *St, /// getLValueVar - Returns an SVal that represents the lvalue of a /// variable. Within RegionStore a variable has an associated /// VarRegion, and the lvalue of the variable is the lvalue of that region. -SVal RegionStoreManager::getLValueVar(const GRState *St, const VarDecl* VD) { - return loc::MemRegionVal(MRMgr.getVarRegion(VD)); +SVal RegionStoreManager::getLValueVar(const GRState *ST, const VarDecl *VD, + const LocationContext *LC) { + return loc::MemRegionVal(MRMgr.getVarRegion(VD, LC)); } /// getLValueCompoundLiteral - Returns an SVal representing the lvalue @@ -1345,18 +1349,20 @@ const GRState *RegionStoreManager::Bind(const GRState *state, Loc L, SVal V) { return state->makeWithStore(RBFactory.Add(B, R, V).getRoot()); } -const GRState *RegionStoreManager::BindDecl(const GRState *state, - const VarDecl* VD, SVal InitVal) { +const GRState *RegionStoreManager::BindDecl(const GRState *ST, + const VarDecl *VD, + const LocationContext *LC, + SVal InitVal) { QualType T = VD->getType(); - VarRegion* VR = MRMgr.getVarRegion(VD); + VarRegion* VR = MRMgr.getVarRegion(VD, LC); if (T->isArrayType()) - return BindArray(state, VR, InitVal); + return BindArray(ST, VR, InitVal); if (T->isStructureType()) - return BindStruct(state, VR, InitVal); + return BindStruct(ST, VR, InitVal); - return Bind(state, ValMgr.makeLoc(VR), InitVal); + return Bind(ST, ValMgr.makeLoc(VR), InitVal); } // FIXME: this method should be merged into Bind().