aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-29 00:38:00 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-29 00:38:00 +0000
commitaee526e77657afd1600276450e9c346953ad51d7 (patch)
treec21f821b09625211f00cbb5018546edb013a23b6 /lib/Frontend/CompilerInstance.cpp
parent4213df3b5da21ce25a4541ca5c447eeb28b515a3 (diff)
Introduce a pure virtual clone() method to DiagnosticConsumer, so that
we have the ability to create a new, distict diagnostic consumer when we go off and build a module. This avoids the currently horribleness where the same diagnostic consumer sees diagnostics for multiple translation units (and multiple SourceManagers!) causing all sorts of havok. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140743 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
-rw-r--r--lib/Frontend/CompilerInstance.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index ce5496562b..554ca352e1 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -141,9 +141,11 @@ static void SetUpDiagnosticLog(const DiagnosticOptions &DiagOpts,
void CompilerInstance::createDiagnostics(int Argc, const char* const *Argv,
DiagnosticConsumer *Client,
- bool ShouldOwnClient) {
+ bool ShouldOwnClient,
+ bool ShouldCloneClient) {
Diagnostics = createDiagnostics(getDiagnosticOpts(), Argc, Argv, Client,
- ShouldOwnClient, &getCodeGenOpts());
+ ShouldOwnClient, ShouldCloneClient,
+ &getCodeGenOpts());
}
llvm::IntrusiveRefCntPtr<DiagnosticsEngine>
@@ -151,6 +153,7 @@ CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts,
int Argc, const char* const *Argv,
DiagnosticConsumer *Client,
bool ShouldOwnClient,
+ bool ShouldCloneClient,
const CodeGenOptions *CodeGenOpts) {
llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
llvm::IntrusiveRefCntPtr<DiagnosticsEngine>
@@ -158,9 +161,12 @@ CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts,
// Create the diagnostic client for reporting errors or for
// implementing -verify.
- if (Client)
- Diags->setClient(Client, ShouldOwnClient);
- else
+ if (Client) {
+ if (ShouldCloneClient)
+ Diags->setClient(Client->clone(*Diags), ShouldOwnClient);
+ else
+ Diags->setClient(Client, ShouldOwnClient);
+ } else
Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), Opts));
// Chain in -verify checker, if requested.
@@ -691,7 +697,8 @@ static void compileModule(CompilerInstance &ImportingInstance,
Instance.setInvocation(&*Invocation);
Instance.createDiagnostics(/*argc=*/0, /*argv=*/0,
&ImportingInstance.getDiagnosticClient(),
- /*ShouldOwnClient=*/false);
+ /*ShouldOwnClient=*/true,
+ /*ShouldCloneClient=*/true);
// Construct a module-generating action.
GeneratePCHAction CreateModuleAction(true);
@@ -699,13 +706,6 @@ static void compileModule(CompilerInstance &ImportingInstance,
// Execute the action to actually build the module in-place.
// FIXME: Need to synchronize when multiple processes do this.
Instance.ExecuteAction(CreateModuleAction);
-
- // Tell the diagnostic client that it's (re-)starting to process a source
- // file.
- // FIXME: This is a hack. We probably want to clone the diagnostic client.
- ImportingInstance.getDiagnosticClient()
- .BeginSourceFile(ImportingInstance.getLangOpts(),
- &ImportingInstance.getPreprocessor());
}
ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,