aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/TextDiagnosticPrinter.cpp
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
commit05f3957c2033f500d9bcc919d4b37d40393c40cf (patch)
treeb53e15c09cb18f98c0ec8a45a0287a0f4e2bee47 /lib/Driver/TextDiagnosticPrinter.cpp
parent3632a35e811096da86d957c3e6ba0e73d75782f5 (diff)
Fix TextDiagnosticPrinter::HandleDiagnostic to handle invalid FullSourceLocs that do not have a SourceManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/TextDiagnosticPrinter.cpp')
-rw-r--r--lib/Driver/TextDiagnosticPrinter.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp
index b19d61c160..36e2d28d2e 100644
--- a/lib/Driver/TextDiagnosticPrinter.cpp
+++ b/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())