[cfe-commits] r152677 - /cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Anna Zaks ganna at apple.com
Tue Mar 13 15:15:58 PDT 2012


Author: zaks
Date: Tue Mar 13 17:15:58 2012
New Revision: 152677

URL: http://llvm.org/viewvc/llvm-project?rev=152677&view=rev
Log:
[analyser] Refactor shouldInline logic into a helper.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=152677&r1=152676&r2=152677&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Tue Mar 13 17:15:58 2012
@@ -127,13 +127,29 @@
   return count;  
 }
 
+// Determine if we should inline the call.
+static bool shouldInline(const FunctionDecl *FD, ExplodedNode *Pred,
+                         AnalysisManager &AMgr) {
+  AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
+  const CFG *CalleeCFG = CalleeADC->getCFG();
+
+  if (getNumberStackFrames(Pred->getLocationContext())
+        == AMgr.InlineMaxStackDepth)
+    return false;
+
+  if (CalleeCFG->getNumBlockIDs() > AMgr.InlineMaxFunctionSize)
+    return false;
+
+  return true;
+}
+
 bool ExprEngine::InlineCall(ExplodedNodeSet &Dst,
                             const CallExpr *CE, 
                             ExplodedNode *Pred) {
   ProgramStateRef state = Pred->getState();
   const Expr *Callee = CE->getCallee();
   const FunctionDecl *FD =
-  state->getSVal(Callee, Pred->getLocationContext()).getAsFunctionDecl();
+    state->getSVal(Callee, Pred->getLocationContext()).getAsFunctionDecl();
   if (!FD || !FD->hasBody(FD))
     return false;
   
@@ -142,16 +158,11 @@
       // FIXME: Handle C++.
       break;
     case Stmt::CallExprClass: {
-      if (getNumberStackFrames(Pred->getLocationContext())
-            == AMgr.InlineMaxStackDepth)
-        return false;
-
-      AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
-      const CFG *CalleeCFG = CalleeADC->getCFG();
-      if (CalleeCFG->getNumBlockIDs() > AMgr.InlineMaxFunctionSize)
+      if (!shouldInline(FD, Pred, AMgr))
         return false;
 
       // Construct a new stack frame for the callee.
+      AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
       const StackFrameContext *CallerSFC =
       Pred->getLocationContext()->getCurrentStackFrame();
       const StackFrameContext *CalleeSFC =





More information about the cfe-commits mailing list