r181505 - [analyzer; alternate arrows] for "loop back" edges add back the extra edge to the closing '}'

Ted Kremenek kremenek at apple.com
Wed May 8 23:55:41 PDT 2013


Author: kremenek
Date: Thu May  9 01:55:41 2013
New Revision: 181505

URL: http://llvm.org/viewvc/llvm-project?rev=181505&view=rev
Log:
[analyzer; alternate arrows] for "loop back" edges add back the extra edge to the closing '}'

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=181505&r1=181504&r2=181505&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Thu May  9 01:55:41 2013
@@ -1722,6 +1722,12 @@ GenerateAlternateExtensivePathDiagnostic
         // Are we jumping to the head of a loop?  Add a special diagnostic.
         if (const Stmt *Loop = BE->getSrc()->getLoopTarget()) {
           PathDiagnosticLocation L(Loop, SM, PDB.LC);
+          const CompoundStmt *CS = NULL;
+
+          if (const ForStmt *FS = dyn_cast<ForStmt>(Loop))
+            CS = dyn_cast<CompoundStmt>(FS->getBody());
+          else if (const WhileStmt *WS = dyn_cast<WhileStmt>(Loop))
+            CS = dyn_cast<CompoundStmt>(WS->getBody());
 
           PathDiagnosticEventPiece *p =
             new PathDiagnosticEventPiece(L, "Looping back to the head "
@@ -1730,6 +1736,12 @@ GenerateAlternateExtensivePathDiagnostic
 
           addEdgeToPath(PD.getActivePath(), PrevLoc, p->getLocation(), PDB.LC);
           PD.getActivePath().push_front(p);
+
+          if (CS) {
+            addEdgeToPath(PD.getActivePath(), PrevLoc,
+                          PathDiagnosticLocation::createEndBrace(CS, SM),
+                          PDB.LC);
+          }
         }
 
         const CFGBlock *BSrc = BE->getSrc();





More information about the cfe-commits mailing list