]> granicus.if.org Git - clang/commitdiff
BugReport::getEndPath() - Only add a Stmt's range to the constructed PathDiagnosticEv...
authorTed Kremenek <kremenek@apple.com>
Mon, 11 May 2009 23:50:59 +0000 (23:50 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 11 May 2009 23:50:59 +0000 (23:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71516 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathDiagnostic.h
lib/Analysis/BugReporter.cpp

index 16b9b06f7b13835dd0917f949c420db7b73f1c35..994b35e5efdac1f7a1238b30e4cd66f8ce221070 100644 (file)
@@ -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();
 
index 23f334239987c0d266436031327dfcc2ae009652..4726eacb320b2957fc37623dd89090ddb700af6b 100644 (file)
@@ -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);