[PATCH] D133988: [clang][deps] Make sure ScanInstance outlives collector

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 15 16:39:59 PDT 2022


jansvoboda11 updated this revision to Diff 460552.
jansvoboda11 added a comment.

Replace `std::shared_ptr` by `Optional` stored on `DependencyScanningAction`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133988/new/

https://reviews.llvm.org/D133988

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ 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<StringRef> ModuleName;
+  Optional<StringRef> ModuleName;
+  Optional<CompilerInstance> ScanInstanceStorage;
   std::shared_ptr<ModuleDepCollector> MDC;
   std::vector<std::string> LastCC1Arguments;
   bool Scanned = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133988.460552.patch
Type: text/x-patch
Size: 1018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220915/bfae39e0/attachment.bin>


More information about the cfe-commits mailing list