Skip to content

Commit 99bc0c1

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. (cherry picked from commit 9651a13)
1 parent 3afe324 commit 99bc0c1

File tree

2 files changed

+12
-0
lines changed

2 files changed

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

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

0 commit comments

Comments
 (0)