]> granicus.if.org Git - clang/commitdiff
Static Analyzer diagnostics visualization: when the last location on a path is end...
authorAnna Zaks <ganna@apple.com>
Wed, 3 Aug 2011 01:57:49 +0000 (01:57 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 3 Aug 2011 01:57:49 +0000 (01:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136761 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporter.cpp

index 84535d5b1e0d555bfce3cd0719eefd66abd65d25..de59943d639db7897b39efdebd3603a3e918e51d 100644 (file)
@@ -1233,14 +1233,29 @@ PathDiagnosticPiece*
 BugReport::getEndPath(BugReporterContext& BRC,
                       const ExplodedNode* EndPathNode) {
 
-  const Stmt* S = getStmt();
+  const ProgramPoint &PP = EndPathNode->getLocation();
+  PathDiagnosticLocation L;
+
+  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 (!S)
-    return NULL;
+  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.