Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. Now
SourceManager is passed by reference, allowing the SourceManager to be
associated with a specific translation unit, and not the entire execution
of the driver.
Modified all users of Diagnostics to comply with this new interface.
Integrated SourceManager as a member variable of TargetInfo. TargetInfo will
eventually be associated with a single translation unit (just like
SourceManager).
Made the SourceManager reference in ASTContext private. Provided accessor
getSourceManager() for clients to use instead. Modified clients to comply with
new interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44878 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/TextDiagnosticPrinter.cpp b/Driver/TextDiagnosticPrinter.cpp
index 463a3d7..d2eaaca 100644
--- a/Driver/TextDiagnosticPrinter.cpp
+++ b/Driver/TextDiagnosticPrinter.cpp
@@ -31,13 +31,13 @@
" diagnostics"));
void TextDiagnosticPrinter::
-PrintIncludeStack(SourceLocation Pos) {
+PrintIncludeStack(SourceLocation Pos, SourceManager& SourceMgr) {
if (Pos.isInvalid()) return;
Pos = SourceMgr.getLogicalLoc(Pos);
// Print out the other include frames first.
- PrintIncludeStack(SourceMgr.getIncludeLoc(Pos));
+ PrintIncludeStack(SourceMgr.getIncludeLoc(Pos),SourceMgr);
unsigned LineNo = SourceMgr.getLineNumber(Pos);
std::cerr << "In file included from " << SourceMgr.getSourceName(Pos)
@@ -46,7 +46,8 @@
/// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s)
/// any characters in LineNo that intersect the SourceRange.
-void TextDiagnosticPrinter::HighlightRange(const SourceRange &R,
+void TextDiagnosticPrinter::HighlightRange(const SourceRange &R,
+ SourceManager& SourceMgr,
unsigned LineNo,
std::string &CaratLine,
const std::string &SourceLine) {
@@ -101,6 +102,7 @@
Diagnostic::Level Level,
SourceLocation Pos,
diag::kind ID,
+ SourceManager& SourceMgr,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
@@ -116,7 +118,7 @@
// "included from" lines.
if (LastWarningLoc != SourceMgr.getIncludeLoc(LPos)) {
LastWarningLoc = SourceMgr.getIncludeLoc(LPos);
- PrintIncludeStack(LastWarningLoc);
+ PrintIncludeStack(LastWarningLoc,SourceMgr);
}
// Compute the column number. Rewind from the current position to the start
@@ -162,7 +164,7 @@
// Highlight all of the characters covered by Ranges with ~ characters.
for (unsigned i = 0; i != NumRanges; ++i)
- HighlightRange(Ranges[i], LineNo, CaratLine, SourceLine);
+ HighlightRange(Ranges[i], SourceMgr, LineNo, CaratLine, SourceLine);
// Next, insert the carat itself.
if (ColNo-1 < CaratLine.size())