diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -174,7 +174,8 @@ Scanned = true; // Create a compiler instance to handle the actual work. - CompilerInstance ScanInstance(std::move(PCHContainerOps)); + ScanInstanceStorage.emplace(std::move(PCHContainerOps)); + CompilerInstance &ScanInstance = *ScanInstanceStorage; ScanInstance.setInvocation(std::move(Invocation)); // Create the compiler's actual diagnostics engine. @@ -304,7 +305,8 @@ bool OptimizeArgs; bool EagerLoadModules; bool DisableFree; - llvm::Optional ModuleName; + Optional ModuleName; + Optional ScanInstanceStorage; std::shared_ptr MDC; std::vector LastCC1Arguments; bool Scanned = false;