Skip to content

Commit d4e879e

Browse files
cachemeifyoucancyndyishida
authored andcommitted
[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 c14ebf0 commit d4e879e

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
@@ -170,6 +170,11 @@ struct ModuleDeps {
170170
/// module. Does not include argv[0].
171171
const std::vector<std::string> &getBuildArguments() const;
172172

173+
/// Experimental: get a copy of the underlying CompilerInvocation before
174+
/// calling `getBuildArguments`. This provides a short cut to inspect/modify
175+
/// the compiler invocation state.
176+
CowCompilerInvocation getUnderlyingCompilerInvocation() const;
177+
173178
private:
174179
friend class ModuleDepCollector;
175180
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)