From: Jordan Rose Date: Thu, 30 May 2013 21:30:17 +0000 (+0000) Subject: Revert "[analyzer; alternate edges] don't add an edge incoming from the start of... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=904fd08edbedeb18b16875dd54b3f1edb049e9b9;p=clang Revert "[analyzer; alternate edges] don't add an edge incoming from the start of a function" ...and make this work correctly in the current codebase. After living on this for a while, it turns out to look very strange for inlined functions that have only a single statement, and somewhat strange for inlined functions in general (since they are still conceptually in the middle of the path, and there is a function-entry path note). It's worth noting that this only affects inlined functions; in the new arrow generation algorithm, the top-level function still starts at the first real statement in the function body, not the enclosing CompoundStmt. This reverts r182078 / dbfa950abe0e55b173286a306ee620eff5f72ea. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182963 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index fe830183fb..2fb1a26cc2 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1557,7 +1557,7 @@ static void addEdgeToPath(PathPieces &path, if (NewLocL.isInvalid() || NewLocL.isMacroID()) return; - if (!PrevLoc.isValid()) { + if (!PrevLoc.isValid() || !PrevLoc.asLocation().isValid()) { PrevLoc = NewLoc; return; } @@ -1608,6 +1608,13 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, // call exit before this point. This means that the path // terminated within the call itself. if (Optional CE = P.getAs()) { + // Add an edge to the start of the function. + const StackFrameContext *CalleeLC = CE->getCalleeContext(); + const Decl *D = CalleeLC->getDecl(); + addEdgeToPath(PD.getActivePath(), PrevLoc, + PathDiagnosticLocation::createBegin(D, SM), + CalleeLC); + // Did we visit an entire call? bool VisitedEntireCall = PD.isWithinCall(); PD.popActivePath(); diff --git a/test/Analysis/edges-new.mm b/test/Analysis/edges-new.mm index 325a2e81d7..cdb49dac9d 100644 --- a/test/Analysis/edges-new.mm +++ b/test/Analysis/edges-new.mm @@ -8624,6 +8624,40 @@ void variousLoops(id input) { // CHECK-NEXT: Entered call from 'mainPlusMain' // CHECK-NEXT: // CHECK-NEXT: +// CHECK-NEXT: kindcontrol +// CHECK-NEXT: edges +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: start +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: line313 +// CHECK-NEXT: col1 +// CHECK-NEXT: file0 +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: line313 +// CHECK-NEXT: col4 +// CHECK-NEXT: file0 +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: end +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: line314 +// CHECK-NEXT: col3 +// CHECK-NEXT: file0 +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: line314 +// CHECK-NEXT: col5 +// CHECK-NEXT: file0 +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: