forked from OSchip/llvm-project
				
			[analyser] Refactor shouldInline logic into a helper.
llvm-svn: 152677
This commit is contained in:
		
							parent
							
								
									6e5b48a6b4
								
							
						
					
					
						commit
						9ff686239a
					
				| 
						 | 
				
			
			@ -127,6 +127,22 @@ static unsigned getNumberStackFrames(const LocationContext *LCtx) {
 | 
			
		|||
  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) {
 | 
			
		||||
| 
						 | 
				
			
			@ -142,16 +158,11 @@ bool ExprEngine::InlineCall(ExplodedNodeSet &Dst,
 | 
			
		|||
      // 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 =
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue