summaryrefslogtreecommitdiffstats
path: root/clang/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
commitd0e9e3a6a5b241d0f84e54694a10a26b1369e42a (patch)
treefcd2d73fdc825b237f2b8dac0cf871989236e35f /clang/lib/Frontend/CompilerInstance.cpp
parent6de48ee8606428d4abab270ac9f8a9d0dd9d4bc4 (diff)
downloadbcm5719-llvm-d0e9e3a6a5b241d0f84e54694a10a26b1369e42a.tar.gz
bcm5719-llvm-d0e9e3a6a5b241d0f84e54694a10a26b1369e42a.zip
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. llvm-svn: 140743
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index ce5496562b1..554ca352e1c 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud