[clang] [clang][deps] Generate command lines lazily (PR #65691)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 16:22:27 PDT 2023


================
@@ -136,9 +138,15 @@ struct ModuleDeps {
   /// determined that the differences are benign for this compilation.
   std::vector<ModuleID> ClangModuleDeps;
 
-  /// Compiler invocation that can be used to build this module. Does not
-  /// include argv[0].
-  std::vector<std::string> BuildArguments;
+  /// Get (or compute) the compiler invocation that can be used to build this
+  /// module. Does not include argv[0].
+  const std::vector<std::string> &getBuildArguments();
+
+private:
+  friend class ModuleDepCollectorPP;
+
+  std::variant<std::shared_ptr<CowCompilerInvocation>, std::vector<std::string>>
+      BuildInvocationOrArguments;
----------------
benlangmuir wrote:

> Also, this should semantically be std::unique_ptr, since we're not sharing the ownership. But I'm not a fan of the move-only semantics that implies. I could wrap it in a unique-ptr-like type that's copyable?

Not sure I understand this - if you copy it you spend the same storage as if it was inlined, so it seems like either you want shared_ptr or inline storage.

I think shared_ptr is reasonable so this can be easily copied around.

https://github.com/llvm/llvm-project/pull/65691


More information about the cfe-commits mailing list