aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend/CreateInvocationFromCommandLine.cpp')
-rw-r--r--clang/lib/Frontend/CreateInvocationFromCommandLine.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index d0b855f..99212b8 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -31,11 +31,15 @@ std::unique_ptr<CompilerInvocation>
clang::createInvocation(ArrayRef<const char *> ArgList,
CreateInvocationOptions Opts) {
assert(!ArgList.empty());
- auto Diags = Opts.Diags
- ? std::move(Opts.Diags)
- : CompilerInstance::createDiagnostics(
- Opts.VFS ? *Opts.VFS : *llvm::vfs::getRealFileSystem(),
- new DiagnosticOptions);
+ std::optional<DiagnosticOptions> LocalDiagOpts;
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
+ if (Opts.Diags) {
+ Diags = std::move(Opts.Diags);
+ } else {
+ LocalDiagOpts.emplace();
+ Diags = CompilerInstance::createDiagnostics(
+ Opts.VFS ? *Opts.VFS : *llvm::vfs::getRealFileSystem(), *LocalDiagOpts);
+ }
SmallVector<const char *, 16> Args(ArgList);