diff options
| author | Anna Zaks <ganna@apple.com> | 2012-03-13 22:15:58 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2012-03-13 22:15:58 +0000 |
| commit | 9ff686239a806e36f62c4c62850b9f59667027e4 (patch) | |
| tree | e145148e7bedf38b0e8368990aaf4012866af56a /clang/lib | |
| parent | 6e5b48a6b4844b6ce62d4e7acca0469136f61693 (diff) | |
| download | bcm5719-llvm-9ff686239a806e36f62c4c62850b9f59667027e4.tar.gz bcm5719-llvm-9ff686239a806e36f62c4c62850b9f59667027e4.zip | |
[analyser] Refactor shouldInline logic into a helper.
llvm-svn: 152677
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index bb4ea99b165..8c9154cf4ce 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -127,13 +127,29 @@ 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) { 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 @@ 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 = |

