Skip to content

Commit cb2b900

Browse files
[clang][DependencyScanning] Add API to expose module CompilerInvocation
Add a new API that returns underlying CompilerInvocation from ModuleDep. This allows clients to inspect and modify the state inside CompilerInvocation before turning that into build arguments.
1 parent 85ec0b3 commit cb2b900

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 the underlying CompilerInvocation before calling
187+
/// `getBuildArguments`. This provides a short cut to inspect/modify the
188+
/// compiler invocation state before turning into build command.
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)