summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-28 20:47:47 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-28 20:47:47 +0000
commit5241832d1dffb02984b839b167f16e563413407c (patch)
treecd4ee7c94fc12d517b56846b9a8105fa4aa18ebf /clang
parentbf16554640037086bec7d6b7a179d8872a4acee9 (diff)
downloadbcm5719-llvm-5241832d1dffb02984b839b167f16e563413407c.tar.gz
bcm5719-llvm-5241832d1dffb02984b839b167f16e563413407c.zip
Fix TextDiagnosticPrinter::HandleDiagnostic to handle invalid FullSourceLocs that do not have a SourceManager.
llvm-svn: 63230
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Driver/TextDiagnosticPrinter.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/clang/lib/Driver/TextDiagnosticPrinter.cpp b/clang/lib/Driver/TextDiagnosticPrinter.cpp
index b19d61c160f..36e2d28d2e3 100644
--- a/clang/lib/Driver/TextDiagnosticPrinter.cpp
+++ b/clang/lib/Driver/TextDiagnosticPrinter.cpp
@@ -95,12 +95,12 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R,
void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
const DiagnosticInfo &Info) {
- const SourceManager &SM = Info.getLocation().getManager();
unsigned ColNo = 0;
// If the location is specified, print out a file/line/col and include trace
// if enabled.
if (Info.getLocation().isValid()) {
+ const SourceManager &SM = Info.getLocation().getManager();
PresumedLoc PLoc = SM.getPresumedLoc(Info.getLocation());
unsigned LineNo = PLoc.getLine();
@@ -142,23 +142,15 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
// Inspect the actual instantiation point of the diagnostic, we don't care
// about presumed locations anymore.
- SourceLocation ILoc = SM.getInstantiationLoc(Info.getLocation());
-
- // Get the file and line that we want to highlight. We only draw ranges
- // that intersect this.
- FileID ILocFID = SM.getFileID(ILoc);
- unsigned LineNo = SM.getLineNumber(ILoc);
-
- // Get the line of the source file. Scan from the location backward and
- // forward to find the start/end of the line.
-
+ FullSourceLoc ILoc = Info.getLocation().getInstantiationLoc();
+
// Rewind from the current position to the start of the line.
- const char *TokInstantiationPtr = SM.getCharacterData(ILoc);
+ const char *TokInstantiationPtr = ILoc.getCharacterData();
const char *LineStart = TokInstantiationPtr-ColNo+1; // Column # is 1-based.
// Compute the line end. Scan forward from the error position to the end of
// the line.
- const char *BufEnd = SM.getBufferData(ILocFID).second;
+ const char *BufEnd = ILoc.getBufferData().second;
const char *LineEnd = TokInstantiationPtr;
while (LineEnd != BufEnd &&
*LineEnd != '\n' && *LineEnd != '\r')
@@ -173,8 +165,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
// Highlight all of the characters covered by Ranges with ~ characters.
for (unsigned i = 0; i != Info.getNumRanges(); ++i)
- HighlightRange(Info.getRange(i), SM, LineNo, ILocFID,
- CaretLine, SourceLine);
+ HighlightRange(Info.getRange(i), ILoc.getManager(), ILoc.getLineNumber(),
+ ILoc.getFileID(), CaretLine, SourceLine);
// Next, insert the caret itself.
if (ColNo-1 < CaretLine.size())
OpenPOWER on IntegriCloud