[cfe-commits] r136761 - /cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Anna Zaks ganna at apple.com
Tue Aug 2 18:57:49 PDT 2011


Author: zaks
Date: Tue Aug  2 20:57:49 2011
New Revision: 136761

URL: http://llvm.org/viewvc/llvm-project?rev=136761&view=rev
Log:
Static Analyzer diagnostics visualization: when the last location on a path is end of the function, the arrow should point to the closing brace, not the statement before it. Patch by Ted Kremenek.

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=136761&r1=136760&r2=136761&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Aug  2 20:57:49 2011
@@ -1233,14 +1233,29 @@
 BugReport::getEndPath(BugReporterContext& BRC,
                       const ExplodedNode* EndPathNode) {
 
-  const Stmt* S = getStmt();
+  const ProgramPoint &PP = EndPathNode->getLocation();
+  PathDiagnosticLocation L;
 
-  if (!S)
-    return NULL;
+  if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&PP)) {
+    const CFGBlock *block = BE->getBlock();
+    if (block->getBlockID() == 0) {
+      L = PathDiagnosticLocation(
+          EndPathNode->getLocationContext()->getDecl()->getBodyRBrace(),
+          BRC.getSourceManager());
+    }
+  }
+
+  if (!L.isValid()) {
+    const Stmt* S = getStmt();
+
+    if (!S)
+      return NULL;
+
+    L = PathDiagnosticLocation(S, BRC.getSourceManager());
+  }
 
   BugReport::ranges_iterator Beg, End;
   llvm::tie(Beg, End) = getRanges();
-  PathDiagnosticLocation L(S, BRC.getSourceManager());
 
   // Only add the statement itself as a range if we didn't specify any
   // special ranges for this report.





More information about the cfe-commits mailing list