Skip to content

Commit 7ad2696

Browse files
authored
Merge pull request #10754 from AnthonyLatsis/stable/20250402
[stable/20250402][clang][DependencyScanning] Add API to expose module CompilerInvocation
2 parents 43cb119 + 2fc8f0a commit 7ad2696

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ struct ModuleDeps {
183183
/// module. Does not include argv[0].
184184
const std::vector<std::string> &getBuildArguments() const;
185185

186+
/// Experimental: get a copy of the underlying CompilerInvocation before
187+
/// calling `getBuildArguments`. This provides a short cut to inspect/modify
188+
/// the compiler invocation state.
189+
CowCompilerInvocation getUnderlyingCompilerInvocation() const;
190+
186191
private:
187192
friend class ModuleDepCollector;
188193
friend class ModuleDepCollectorPP;

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ const std::vector<std::string> &ModuleDeps::getBuildArguments() const {
4646
return std::get<std::vector<std::string>>(BuildInfo);
4747
}
4848

49+
CowCompilerInvocation ModuleDeps::getUnderlyingCompilerInvocation() const {
50+
assert(std::holds_alternative<CowCompilerInvocation>(BuildInfo) &&
51+
"ModuleDeps doesn't hold compiler invocation");
52+
return *std::get_if<CowCompilerInvocation>(&BuildInfo);
53+
}
54+
4955
static void
5056
optimizeHeaderSearchOpts(HeaderSearchOptions &Opts, ASTReader &Reader,
5157
const serialization::ModuleFile &MF,

0 commit comments

Comments
 (0)