[cfe-commits] r83936 - /cfe/trunk/lib/Analysis/CallInliner.cpp

Zhongxing Xu xuzhongxing at gmail.com
Mon Oct 12 19:36:42 PDT 2009


Author: zhongxingxu
Date: Mon Oct 12 21:36:42 2009
New Revision: 83936

URL: http://llvm.org/viewvc/llvm-project?rev=83936&view=rev
Log:
Now we can call into another function with the CallInliner transfer function.

Modified:
    cfe/trunk/lib/Analysis/CallInliner.cpp

Modified: cfe/trunk/lib/Analysis/CallInliner.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallInliner.cpp?rev=83936&r1=83935&r2=83936&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CallInliner.cpp (original)
+++ cfe/trunk/lib/Analysis/CallInliner.cpp Mon Oct 12 21:36:42 2009
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/Analysis/PathSensitive/GRExprEngine.h"
 #include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
 
 using namespace clang;
@@ -33,7 +34,40 @@
 void CallInliner::EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine,
                            GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L,
                            ExplodedNode* Pred) {
-  assert(0 && "TO BE IMPLEMENTED");
+  FunctionDecl const *FD = L.getAsFunctionDecl();
+  if (!FD)
+    return; // GRExprEngine is responsible for the autotransition.
+
+  // Make a new LocationContext.
+  StackFrameContext const *LocCtx =
+  Engine.getAnalysisManager().getStackFrame(FD, Pred->getLocationContext(), CE);
+
+  CFGBlock const *Entry = &(LocCtx->getCFG()->getEntry());
+
+  assert (Entry->empty() && "Entry block must be empty.");
+
+  assert (Entry->succ_size() == 1 && "Entry block must have 1 successor.");
+
+  // Get the solitary successor.
+  CFGBlock const *SuccB = *(Entry->succ_begin());
+
+  // Construct an edge representing the starting location in the function.
+  BlockEdge Loc(Entry, SuccB, LocCtx);
+
+  GRState const *state = Builder.GetState(Pred);  
+  state = Engine.getStoreManager().EnterStackFrame(state, LocCtx);
+
+  bool isNew;
+  ExplodedNode *SuccN = Engine.getGraph().getNode(Loc, state, &isNew);
+  SuccN->addPredecessor(Pred, Engine.getGraph());
+
+  Builder.Deferred.erase(Pred);
+
+  // This is a hack. We really should not use the GRStmtNodeBuilder.
+  if (isNew)
+    Builder.getWorkList()->Enqueue(SuccN);
+
+  Builder.HasGeneratedNode = true;
 }
   
 GRTransferFuncs *clang::CreateCallInliner(ASTContext &ctx) {





More information about the cfe-commits mailing list