Skip to content

[clang][DependencyScanning] Add API to expose module CompilerInvocation #10667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: stable/20240723
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ struct ModuleDeps {
/// module. Does not include argv[0].
const std::vector<std::string> &getBuildArguments() const;

/// Experimental: get the underlying CompilerInvocation before calling
/// `getBuildArguments`. This provides a short cut to inspect/modify the
/// compiler invocation state before turning into build command.
CowCompilerInvocation &getUnderlyingCompilerInvocation() const;

private:
friend class ModuleDepCollector;
friend class ModuleDepCollectorPP;
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const std::vector<std::string> &ModuleDeps::getBuildArguments() const {
return std::get<std::vector<std::string>>(BuildInfo);
}

CowCompilerInvocation &ModuleDeps::getUnderlyingCompilerInvocation() const {
assert(std::holds_alternative<CowCompilerInvocation>(BuildInfo) &&
"ModuleDeps doesn't hold compiler invocation");
return *std::get_if<CowCompilerInvocation>(&BuildInfo);
}

static void
optimizeHeaderSearchOpts(HeaderSearchOptions &Opts, ASTReader &Reader,
const serialization::ModuleFile &MF,
Expand Down