diff options
-rw-r--r-- | include/clang/Analysis/PathSensitive/AnalysisContext.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/Store.h | 8 | ||||
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 22 |
3 files changed, 32 insertions, 0 deletions
diff --git a/include/clang/Analysis/PathSensitive/AnalysisContext.h b/include/clang/Analysis/PathSensitive/AnalysisContext.h index ab035386c5..ffe282d3ca 100644 --- a/include/clang/Analysis/PathSensitive/AnalysisContext.h +++ b/include/clang/Analysis/PathSensitive/AnalysisContext.h @@ -117,6 +117,8 @@ public: const Stmt *s) : LocationContext(StackFrame, ctx, parent), CallSite(s) {} + Stmt const *getCallSite() const { return CallSite; } + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getAnalysisContext(), getParent(), CallSite); } diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h index aaf244bdb9..c274435728 100644 --- a/include/clang/Analysis/PathSensitive/Store.h +++ b/include/clang/Analysis/PathSensitive/Store.h @@ -32,6 +32,7 @@ class Stmt; class Expr; class ObjCIvarDecl; class SubRegionMap; +class StackFrameContext; class StoreManager { protected: @@ -157,6 +158,13 @@ public: return state; } + /// EnterStackFrame - Let the StoreManager to do something when execution + /// engine is about to execute into a callee. + virtual const GRState *EnterStackFrame(const GRState *state, + const StackFrameContext *frame) { + assert(0 && "EnterStackFrame() is not supported in this Store Model."); + } + virtual void print(Store store, llvm::raw_ostream& Out, const char* nl, const char *sep) = 0; diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index f0bf072fa4..63bfa97c4d 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -353,6 +353,9 @@ public: void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper, llvm::SmallVectorImpl<const MemRegion*>& RegionRoots); + const GRState *EnterStackFrame(const GRState *state, + const StackFrameContext *frame); + //===------------------------------------------------------------------===// // Region "extents". //===------------------------------------------------------------------===// @@ -1820,6 +1823,25 @@ void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc, state.setStore(store); } +GRState const *RegionStoreManager::EnterStackFrame(GRState const *state, + StackFrameContext const *frame) { + FunctionDecl const *FD = cast<FunctionDecl>(frame->getDecl()); + CallExpr const *CE = cast<CallExpr>(frame->getCallSite()); + + FunctionDecl::param_const_iterator PI = FD->param_begin(); + + CallExpr::const_arg_iterator AI = CE->arg_begin(), AE = CE->arg_end(); + + // Copy the arg expression value to the arg variables. + for (; AI != AE; ++AI, ++PI) { + SVal ArgVal = state->getSVal(*AI); + MemRegion *R = MRMgr.getVarRegion(*PI, frame); + state = Bind(state, ValMgr.makeLoc(R), ArgVal); + } + + return state; +} + //===----------------------------------------------------------------------===// // Utility methods. //===----------------------------------------------------------------------===// |