diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-10-15 00:33:06 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-10-15 00:33:06 +0000 |
commit | d512c1edf0f1425eae61c13812ea4000fcabc609 (patch) | |
tree | 56fb4d66076b59454cb6834818b8f11daefa53e3 /clang/lib/Frontend | |
parent | cba08bd9b2f66868d27387c4f7ea06b8150d75f7 (diff) | |
download | bcm5719-llvm-d512c1edf0f1425eae61c13812ea4000fcabc609.tar.gz bcm5719-llvm-d512c1edf0f1425eae61c13812ea4000fcabc609.zip |
Frontend: Don't accept null DiagnosticsEngines when building ASTUnits
The various ways to create an ASTUnit all take a refcounted pointer to
a diagnostics engine as an argument, and if it isn't pointing at
anything they initialize it. This is a pretty confusing API, and it
really makes more sense for the caller to initialize the thing since
they control the lifetime anyway.
This fixes the one caller that didn't bother initializing the pointer
and asserts that the argument is initialized.
llvm-svn: 219752
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 8a77d87f64e..8742a54c01c 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -642,20 +642,11 @@ ASTUnit::getBufferForFile(StringRef Filename, std::string *ErrorStr) { } /// \brief Configure the diagnostics object for use with ASTUnit. -void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> &Diags, +void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags, ASTUnit &AST, bool CaptureDiagnostics) { - if (!Diags.get()) { - // No diagnostics engine was provided, so create our own diagnostics object - // with the default options. - DiagnosticConsumer *Client = nullptr; - if (CaptureDiagnostics) - Client = new StoredDiagnosticConsumer(AST.StoredDiagnostics); - Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(), - Client, - /*ShouldOwnClient=*/true); - } else if (CaptureDiagnostics) { + assert(Diags.get() && "no DiagnosticsEngine was provided"); + if (CaptureDiagnostics) Diags->setClient(new StoredDiagnosticConsumer(AST.StoredDiagnostics)); - } } std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile( @@ -1928,11 +1919,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies, bool UserFilesAreVolatile, bool ForSerialization, std::unique_ptr<ASTUnit> *ErrAST) { - if (!Diags.get()) { - // No diagnostics engine was provided, so create our own diagnostics object - // with the default options. - Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); - } + assert(Diags.get() && "no DiagnosticsEngine was provided"); SmallVector<StoredDiagnostic, 4> StoredDiagnostics; |