diff options
author | Anna Zaks <ganna@apple.com> | 2012-09-10 23:35:11 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-09-10 23:35:11 +0000 |
commit | 4ea9b89ff6dc50d5404eb56cad5e5870bce49ef2 (patch) | |
tree | d13fb6a6a77b4488f8fb3089790c4491721b0f8f /lib/StaticAnalyzer | |
parent | 73c87d0c7e34c4bd33f2bb3674687a9d46c8dfec (diff) |
[analyzer] Do not count calls to small functions when computing stack
depth.
We only want to count how many substantial functions we inlined. This
is an improvement to r163558.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 54c66d37ba..eb5395e93c 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -247,18 +247,33 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) { } } -static void examineStackFrames(const Decl *D, const LocationContext *LCtx, +void ExprEngine::examineStackFrames(const Decl *D, const LocationContext *LCtx, bool &IsRecursive, unsigned &StackDepth) { IsRecursive = false; StackDepth = 0; + while (LCtx) { if (const StackFrameContext *SFC = dyn_cast<StackFrameContext>(LCtx)) { - ++StackDepth; - if (SFC->getDecl() == D) + const Decl *DI = SFC->getDecl(); + + // Mark recursive (and mutually recursive) functions and always count + // them when measuring the stack depth. + if (DI == D) { IsRecursive = true; + ++StackDepth; + LCtx = LCtx->getParent(); + continue; + } + + // Do not count the small functions when determining the stack depth. + AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(DI); + const CFG *CalleeCFG = CalleeADC->getCFG(); + if (CalleeCFG->getNumBlockIDs() > AMgr.options.getAlwaysInlineSize()) + ++StackDepth; } LCtx = LCtx->getParent(); } + } static bool IsInStdNamespace(const FunctionDecl *FD) { |