[cfe-commits] r65088 - in /cfe/trunk: include/clang/Driver/TextDiagnosticPrinter.h lib/Driver/TextDiagnosticPrinter.cpp
Chris Lattner
sabre at nondot.org
Thu Feb 19 16:18:51 PST 2009
Author: lattner
Date: Thu Feb 19 18:18:51 2009
New Revision: 65088
URL: http://llvm.org/viewvc/llvm-project?rev=65088&view=rev
Log:
refactor, pass ranges down instead of the whole
DiagnosticInfo.
Modified:
cfe/trunk/include/clang/Driver/TextDiagnosticPrinter.h
cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/include/clang/Driver/TextDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/TextDiagnosticPrinter.h?rev=65088&r1=65087&r2=65088&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/TextDiagnosticPrinter.h (original)
+++ cfe/trunk/include/clang/Driver/TextDiagnosticPrinter.h Thu Feb 19 18:18:51 2009
@@ -46,8 +46,9 @@
std::string &CaretLine,
const std::string &SourceLine);
- void EmitCaretDiagnostic(const DiagnosticInfo &Info,
- SourceLocation Loc, SourceManager &SM);
+ void EmitCaretDiagnostic(SourceLocation Loc,
+ const SourceRange *Ranges, unsigned NumRanges,
+ SourceManager &SM);
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
const DiagnosticInfo &Info);
Modified: cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp?rev=65088&r1=65087&r2=65088&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp Thu Feb 19 18:18:51 2009
@@ -101,8 +101,9 @@
CaretLine[i] = '~';
}
-void TextDiagnosticPrinter::EmitCaretDiagnostic(const DiagnosticInfo &Info,
- SourceLocation Loc,
+void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
+ const SourceRange *Ranges,
+ unsigned NumRanges,
SourceManager &SM) {
assert(!Loc.isInvalid() && "must have a valid source location here");
@@ -110,7 +111,7 @@
// points. This more closely correlates to what the user writes.
if (!Loc.isFileID()) {
SourceLocation OneLevelUp = SM.getImmediateInstantiationRange(Loc).first;
- EmitCaretDiagnostic(Info, OneLevelUp, SM);
+ EmitCaretDiagnostic(OneLevelUp, Ranges, NumRanges, SM);
Loc = SM.getInstantiationLoc(SM.getImmediateSpellingLoc(Loc));
@@ -154,11 +155,11 @@
std::string CaretLine(LineEnd-LineStart, ' ');
// Highlight all of the characters covered by Ranges with ~ characters.
- if (Info.getNumRanges()) {
+ if (NumRanges) {
unsigned LineNo = SM.getLineNumber(FID, FileOffset);
- for (unsigned i = 0; i != Info.getNumRanges(); ++i)
- HighlightRange(Info.getRange(i), SM, LineNo, FID, CaretLine, SourceLine);
+ for (unsigned i = 0, e = NumRanges; i != e; ++i)
+ HighlightRange(Ranges[i], SM, LineNo, FID, CaretLine, SourceLine);
}
// Next, insert the caret itself.
@@ -244,9 +245,14 @@
// Cache the LastLoc, it allows us to omit duplicate source/caret spewage.
LastLoc = Info.getLocation();
- // Inspect the actual source location of the diagnostic, we don't care
- // about presumed locations anymore.
- EmitCaretDiagnostic(Info, LastLoc, LastLoc.getManager());
+ // Get the ranges into a local array we can hack on.
+ SourceRange Ranges[10];
+ unsigned NumRanges = Info.getNumRanges();
+ assert(NumRanges < 10 && "Out of space");
+ for (unsigned i = 0; i != NumRanges; ++i)
+ Ranges[i] = Info.getRange(i);
+
+ EmitCaretDiagnostic(LastLoc, Ranges, NumRanges, LastLoc.getManager());
}
OS.flush();
More information about the cfe-commits
mailing list