]> granicus.if.org Git - clang/commitdiff
Add an initial implementation of EnterStackFrame() to the StoreManager.
authorZhongxing Xu <xuzhongxing@gmail.com>
Tue, 13 Oct 2009 02:24:55 +0000 (02:24 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Tue, 13 Oct 2009 02:24:55 +0000 (02:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83934 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/AnalysisContext.h
include/clang/Analysis/PathSensitive/Store.h
lib/Analysis/RegionStore.cpp

index ab035386c522aaa8df74708fe928347726d28059..ffe282d3caa39f6342fb7cd741e5af10048dc96c 100644 (file)
@@ -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);
   }
index aaf244bdb90c635e39779a469ddb2e3928734ec8..c27443572814d3819f5bbcb438af2aec1e97d8fd 100644 (file)
@@ -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;
 
index f0bf072fa4fdf19ed8177eb75b04a8efc4d9c317..63bfa97c4d13ea5c95a27d07cd29ed503998c4ec 100644 (file)
@@ -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.
 //===----------------------------------------------------------------------===//