[clang] [clang][deps] Generate command lines lazily (PR #65691)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 7 16:13:11 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;
----------------
jansvoboda11 wrote:
The size of `ModuleDeps` used to be 200B. Storing `CowCompilerInvocation` directly would increase that to 360B, while just pointing to it keeps it at 208B. WDYT about the trade-offs?
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?
https://github.com/llvm/llvm-project/pull/65691
More information about the cfe-commits
mailing list