diff options
author | Anna Zaks <ganna@apple.com> | 2011-08-03 01:57:49 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-08-03 01:57:49 +0000 |
commit | 59546b8f79bd020362c4478628111c0beb0b1dc0 (patch) | |
tree | a6b45e9bebb2ac1b8abcac2ec84868c31517ebee /clang/lib/StaticAnalyzer/Core/BugReporter.cpp | |
parent | cf901ed229a15fb1f12ac6c8979b5e70936fa355 (diff) | |
download | bcm5719-llvm-59546b8f79bd020362c4478628111c0beb0b1dc0.tar.gz bcm5719-llvm-59546b8f79bd020362c4478628111c0beb0b1dc0.zip |
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.
llvm-svn: 136761
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 84535d5b1e0..de59943d639 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -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. |