From: Ted Kremenek Date: Tue, 7 Feb 2012 02:26:17 +0000 (+0000) Subject: Tweak BugReporter extensive diagnostics to not add edges between function calls. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5de4fdb8de700f95b0b863a9e5a4a508de17a034;p=clang Tweak BugReporter extensive diagnostics to not add edges between function calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149959 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 5101827d71..299fad1478 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -927,6 +927,12 @@ public: rawAddEdge(L); } + void flushLocations() { + while (!CLocs.empty()) + popLocation(); + PrevLoc = PathDiagnosticLocation(); + } + void addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd = false); void rawAddEdge(PathDiagnosticLocation NewLoc); @@ -1132,8 +1138,27 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD, ProgramPoint P = N->getLocation(); do { + if (const CallExit *CE = dyn_cast(&P)) { + const StackFrameContext *LCtx = + CE->getLocationContext()->getCurrentStackFrame(); + PathDiagnosticLocation Loc(LCtx->getCallSite(), + PDB.getSourceManager(), + LCtx); + EB.addEdge(Loc, true); + EB.flushLocations(); + break; + } + + // Was the predecessor in a different stack frame? + if (NextNode && + !isa(NextNode->getLocation()) && + NextNode->getLocationContext()->getCurrentStackFrame() != + N->getLocationContext()->getCurrentStackFrame()) { + EB.flushLocations(); + } + // Block edges. - if (const BlockEdge *BE = dyn_cast(&P)) { + if (const BlockEdge *BE = dyn_cast(&P)) { const CFGBlock &Blk = *BE->getSrc(); const Stmt *Term = Blk.getTerminator(); @@ -1182,6 +1207,8 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD, break; } + + } while (0); if (!NextNode)