Skip to content

Commit 9651a13

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 1756d9f commit 9651a13

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

228+
/// Experimental: get a copy of the underlying CompilerInvocation before
229+
/// calling `getBuildArguments`. This provides a short cut to inspect/modify
230+
/// the compiler invocation state.
231+
CowCompilerInvocation getUnderlyingCompilerInvocation() const;
232+
228233
private:
229234
friend class ModuleDepCollector;
230235
friend class ModuleDepCollectorPP;

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ void PrebuiltModuleASTAttrs::updateDependentsNotInStableDirs(
5656
}
5757
}
5858

59+
CowCompilerInvocation ModuleDeps::getUnderlyingCompilerInvocation() const {
60+
assert(std::holds_alternative<CowCompilerInvocation>(BuildInfo) &&
61+
"ModuleDeps doesn't hold compiler invocation");
62+
return *std::get_if<CowCompilerInvocation>(&BuildInfo);
63+
}
64+
5965
static void
6066
optimizeHeaderSearchOpts(HeaderSearchOptions &Opts, ASTReader &Reader,
6167
const serialization::ModuleFile &MF,

0 commit comments

Comments
 (0)