summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-11 23:50:59 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-11 23:50:59 +0000
commit5fb7847fbff1c8808e589426ebacabf11339f07c (patch)
treeff11c9a253bcad6f71a980c1e7ca77184a591bd6
parentbd7d11f7704cde8419aac2945ed86455ff5914b1 (diff)
downloadbcm5719-llvm-5fb7847fbff1c8808e589426ebacabf11339f07c.tar.gz
bcm5719-llvm-5fb7847fbff1c8808e589426ebacabf11339f07c.zip
BugReport::getEndPath() - Only add a Stmt's range to the constructed PathDiagnosticEventPiece if the BugReport contained no explicit ranges.
llvm-svn: 71516
-rw-r--r--clang/include/clang/Analysis/PathDiagnostic.h9
-rw-r--r--clang/lib/Analysis/BugReporter.cpp13
2 files changed, 13 insertions, 9 deletions
diff --git a/clang/include/clang/Analysis/PathDiagnostic.h b/clang/include/clang/Analysis/PathDiagnostic.h
index 16b9b06f7b1..994b35e5efd 100644
--- a/clang/include/clang/Analysis/PathDiagnostic.h
+++ b/clang/include/clang/Analysis/PathDiagnostic.h
@@ -244,11 +244,12 @@ class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
public:
PathDiagnosticEventPiece(const PathDiagnosticLocation &pos,
- const std::string& s)
- : PathDiagnosticSpotPiece(pos, s, Event) {}
+ const std::string& s, bool addPosRange = true)
+ : PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
- PathDiagnosticEventPiece(const PathDiagnosticLocation &pos, const char* s)
- : PathDiagnosticSpotPiece(pos, s, Event) {}
+ PathDiagnosticEventPiece(const PathDiagnosticLocation &pos, const char* s,
+ bool addPosRange = true)
+ : PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
~PathDiagnosticEventPiece();
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index 23f33423998..4726eacb320 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -1198,13 +1198,16 @@ BugReport::getEndPath(BugReporterContext& BRC,
if (!S)
return NULL;
-
- FullSourceLoc L(S->getLocStart(), BRC.getSourceManager());
- PathDiagnosticPiece* P = new PathDiagnosticEventPiece(L, getDescription());
-
+
const SourceRange *Beg, *End;
- getRanges(BRC.getBugReporter(), Beg, End);
+ getRanges(BRC.getBugReporter(), Beg, End);
+ PathDiagnosticLocation L(S, BRC.getSourceManager());
+ // Only add the statement itself as a range if we didn't specify any
+ // special ranges for this report.
+ PathDiagnosticPiece* P = new PathDiagnosticEventPiece(L, getDescription(),
+ Beg == End);
+
for (; Beg != End; ++Beg)
P->addRange(*Beg);
OpenPOWER on IntegriCloud