From fb05406cefd5d3b98c10afaa5a3b309eb8db8eb4 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 22 Apr 2009 20:36:26 +0000 Subject: BugReporter (extensive diagnostics): always add an edge if there is no location context. llvm-svn: 69823 --- clang/lib/Analysis/BugReporter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index d27ead442e9..6872ab622ea 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/lib/Analysis/BugReporter.cpp @@ -788,7 +788,11 @@ class VISIBILITY_HIDDEN EdgeBuilder { void popLocation() { PathDiagnosticLocation L = CLocs.back(); - if (L.asLocation().isFileID()) rawAddEdge(CLocs.back()); + if (L.asLocation().isFileID()) { + // For contexts, we only one the first character as the range. + L = PathDiagnosticLocation(L.asLocation(), L.getManager()); + rawAddEdge(CLocs.back()); + } CLocs.pop_back(); } @@ -946,6 +950,9 @@ void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) { // Context does not contain the location. Flush it. popLocation(); } + + // If we reach here, there is no enclosing context. Just add the edge. + rawAddEdge(NewLoc); } void EdgeBuilder::addContext(const Stmt *S) { -- cgit v1.2.3