ProgramStateRef St, SVal location,
const ProgramPointTag *tag, bool isLoad);
+ /// Count the stack depth and determine if the call is recursive.
+ void examineStackFrames(const Decl *D, const LocationContext *LCtx,
+ bool &IsRecursive, unsigned &StackDepth);
+
bool shouldInlineDecl(const Decl *D, ExplodedNode *Pred);
bool inlineCall(const CallEvent &Call, const Decl *D, NodeBuilder &Bldr,
ExplodedNode *Pred, ProgramStateRef State);
}
}
-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) {
void clang_analyzer_eval(int);
int nested5() {
+ if (5 < 3)
+ return 0;
+ else
+ if (3 == 3)
+ return 0;
return 0;
}
int nested4() {
int callRecursive() {
return recursive();
}
+
+int mutuallyRecursive1();
+
+int mutuallyRecursive2() {
+ return mutuallyRecursive1();
+}
+
+int mutuallyRecursive1() {
+ return mutuallyRecursive2();
+}
+int callMutuallyRecursive() {
+ return mutuallyRecursive1();
+}