aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/TextDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-05-10 05:03:45 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-05-10 05:03:45 +0000
commit16afdf76b6f12e41ff6f6e6828bfb1d4732523ba (patch)
treeff1e52eb429bff15196fbb565d94225d940c70f6 /lib/Frontend/TextDiagnosticPrinter.cpp
parentdd44f34301316b814277d6a8c146d86c7115330b (diff)
Fix an assertion hit when the serialized diagnostics writer receive a diagnostic
from the frontend when the location is invalid and the SourceManager null. Instead of keeping the SourceManager object in DiagnosticRenderer, propagate it to the calls accordingly (as reference when it is expected to not be null, or pointer when it may be null). This effectively makes DiagnosticRenderer not tied to a specific SourceManager, removing a hack from TextDiagnosticPrinter. rdar://11386874 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 6445a0cc79..d07917f234 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -27,7 +27,7 @@ using namespace clang;
TextDiagnosticPrinter::TextDiagnosticPrinter(raw_ostream &os,
const DiagnosticOptions &diags,
bool _OwnsOutputStream)
- : OS(os), LangOpts(0), DiagOpts(&diags), SM(0),
+ : OS(os), DiagOpts(&diags),
OwnsOutputStream(_OwnsOutputStream) {
}
@@ -38,11 +38,11 @@ TextDiagnosticPrinter::~TextDiagnosticPrinter() {
void TextDiagnosticPrinter::BeginSourceFile(const LangOptions &LO,
const Preprocessor *PP) {
- LangOpts = &LO;
+ // Build the TextDiagnostic utility.
+ TextDiag.reset(new TextDiagnostic(OS, LO, *DiagOpts));
}
void TextDiagnosticPrinter::EndSourceFile() {
- LangOpts = 0;
TextDiag.reset(0);
}
@@ -152,22 +152,16 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
}
// Assert that the rest of our infrastructure is setup properly.
- assert(LangOpts && "Unexpected diagnostic outside source file processing");
assert(DiagOpts && "Unexpected diagnostic without options set");
assert(Info.hasSourceManager() &&
"Unexpected diagnostic with no source manager");
-
- // Rebuild the TextDiagnostic utility if missing or the source manager has
- // changed.
- if (!TextDiag || SM != &Info.getSourceManager()) {
- SM = &Info.getSourceManager();
- TextDiag.reset(new TextDiagnostic(OS, *SM, *LangOpts, *DiagOpts));
- }
+ assert(TextDiag && "Unexpected diagnostic outside source file processing");
TextDiag->emitDiagnostic(Info.getLocation(), Level, DiagMessageStream.str(),
Info.getRanges(),
llvm::makeArrayRef(Info.getFixItHints(),
- Info.getNumFixItHints()));
+ Info.getNumFixItHints()),
+ &Info.getSourceManager());
OS.flush();
}