Skip to content

NFCI: [clang][deps] Simplify handling of main TU context hash #141966

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

Merged
merged 1 commit into from
May 29, 2025
Merged
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 @@ -325,8 +325,6 @@ class ModuleDepCollector final : public DependencyCollector {
const ArrayRef<StringRef> StableDirs;
/// Path to the main source file.
std::string MainFile;
/// Hash identifying the compilation conditions of the current TU.
std::string ContextHash;
/// Non-modular file dependencies. This includes the main source file and
/// textually included header files.
std::vector<std::string> FileDeps;
Expand Down
10 changes: 3 additions & 7 deletions clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,6 @@ void ModuleDepCollectorPP::LexedFileChanged(FileID FID,
if (Reason != LexedFileChangeReason::EnterFile)
return;

// This has to be delayed as the context hash can change at the start of
// `CompilerInstance::ExecuteAction`.
if (MDC.ContextHash.empty()) {
MDC.ContextHash = MDC.ScanInstance.getInvocation().getModuleHash();
MDC.Consumer.handleContextHash(MDC.ContextHash);
}

SourceManager &SM = MDC.ScanInstance.getSourceManager();

// Dependency generation really does want to go all the way to the
Expand Down Expand Up @@ -720,6 +713,9 @@ void ModuleDepCollectorPP::EndOfMainFile() {
for (const Module *M : MDC.DirectModularDeps)
handleTopLevelModule(M);

MDC.Consumer.handleContextHash(
MDC.ScanInstance.getInvocation().getModuleHash());

MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);

if (MDC.Service.getFormat() == ScanningOutputFormat::P1689)
Expand Down
Loading