This patch uses the new CompilerInvocation::generateCC1CommandLine to generate the full canonical command line for modular dependencies, instead of only appending additional arguments.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h | ||
---|---|---|
78–80 | Looks like this will be a deep copy, but it doesn't look like it's being modified. Can this just be a const &, taken in the ModuleDeps constructor? Or is there a lifetime reason this needs to be as it is? | |
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp | ||
25 | Should this call any of the resetNonModularOptions() functions, or are those intentionally omitted? | |
26–27 | Should FrontendOpts gain a resetNonModularOptions()? | |
63 | I think guaranteed copy elision means this won't be a deep copy of the return, but it might be nice to add a move constructor for CompilerInvocation so it's more obvious. |
Share ModuleDeps::Invocation
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h | ||
---|---|---|
78–80 | It can't be const & for two reasons:
I think the best solution would be to extract the shared_ptr from CompilerInstance, share it across ModuleDeps instances and only do a deep copy when actually generating the command line. | |
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp | ||
25 | My intent for this patch was to simply take the work @Bigcheese has done downstream with -remove-preceeding-explicit-module-build-incompatible-options and port it to CompilerInvocation. Calling resetNonModularOptions() here would be the next step I intend to do in a future patch. I also think disabling implicit module maps here is not correct, as that seems to disable inferred top-level modules. | |
26–27 | Most likely yes. I'd like to look into it in a next patch. | |
63 | That's intentional. The deep copy is performed inside the function. Shouldn't the move constructor of CompilerInvocation be defaulted? |
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp | ||
---|---|---|
63 | s/defaulted/implicitly-defined/ |
LGTM, just a couple of other comments inline.
clang/include/clang/Frontend/CompilerInstance.h | ||
---|---|---|
230 | Is get*Ptr() already used in CompilerInstance? If so, matching that style sounds great. Otherwise I have a slight preference for getShared*(). | |
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h | ||
78–80 | Using shared_ptr seems right given the lifetime issues. FWIW, I think const CompilerInvocation* is probably simpler to work with than Optional<reference_wrapper<const CompilerInvocation>>. | |
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp | ||
63 | Explicitly declaring a copy constructor suppresses the implicit move constructor. But adding a move with = default is probably all that's needed. |
Thanks for the review!
clang/include/clang/Frontend/CompilerInstance.h | ||
---|---|---|
230 | Yes, this naming pattern is already used:
and getShared*() is not being used. | |
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp | ||
63 | I see, thanks for pointing that out. I explicitly defaulted move constructor/assignment in D100473. |
Is get*Ptr() already used in CompilerInstance? If so, matching that style sounds great. Otherwise I have a slight preference for getShared*().