[analyser] Refactor shouldInline logic into a helper.
llvm-svn: 152677
This commit is contained in:
parent
6e5b48a6b4
commit
9ff686239a
|
|
@ -127,13 +127,29 @@ static unsigned getNumberStackFrames(const LocationContext *LCtx) {
|
||||||
return count;
|
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,
|
bool ExprEngine::InlineCall(ExplodedNodeSet &Dst,
|
||||||
const CallExpr *CE,
|
const CallExpr *CE,
|
||||||
ExplodedNode *Pred) {
|
ExplodedNode *Pred) {
|
||||||
ProgramStateRef state = Pred->getState();
|
ProgramStateRef state = Pred->getState();
|
||||||
const Expr *Callee = CE->getCallee();
|
const Expr *Callee = CE->getCallee();
|
||||||
const FunctionDecl *FD =
|
const FunctionDecl *FD =
|
||||||
state->getSVal(Callee, Pred->getLocationContext()).getAsFunctionDecl();
|
state->getSVal(Callee, Pred->getLocationContext()).getAsFunctionDecl();
|
||||||
if (!FD || !FD->hasBody(FD))
|
if (!FD || !FD->hasBody(FD))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -142,16 +158,11 @@ bool ExprEngine::InlineCall(ExplodedNodeSet &Dst,
|
||||||
// FIXME: Handle C++.
|
// FIXME: Handle C++.
|
||||||
break;
|
break;
|
||||||
case Stmt::CallExprClass: {
|
case Stmt::CallExprClass: {
|
||||||
if (getNumberStackFrames(Pred->getLocationContext())
|
if (!shouldInline(FD, Pred, AMgr))
|
||||||
== AMgr.InlineMaxStackDepth)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
|
|
||||||
const CFG *CalleeCFG = CalleeADC->getCFG();
|
|
||||||
if (CalleeCFG->getNumBlockIDs() > AMgr.InlineMaxFunctionSize)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Construct a new stack frame for the callee.
|
// Construct a new stack frame for the callee.
|
||||||
|
AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
|
||||||
const StackFrameContext *CallerSFC =
|
const StackFrameContext *CallerSFC =
|
||||||
Pred->getLocationContext()->getCurrentStackFrame();
|
Pred->getLocationContext()->getCurrentStackFrame();
|
||||||
const StackFrameContext *CalleeSFC =
|
const StackFrameContext *CalleeSFC =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue