This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] NFC: Stop assuming the TU's context hash
ClosedPublic

Authored by jansvoboda11 on May 14 2021, 2:00 AM.

Details

Summary

The context hash of modular dependencies can be different from the context hash of the original translation unit if we modify their CompilerInvocations.

Stop assuming the TU's context hash everywhere.

No functionality change here, since we're still currently using the unmodified TU CompilerInvocation to compute the context hash.

Diff Detail

Event Timeline

jansvoboda11 requested review of this revision.May 14 2021, 2:00 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2021, 2:00 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Use std::unordered_map again

Shuffle lines around to minimize diff in the next patch

jansvoboda11 added inline comments.May 14 2021, 5:04 AM
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
147

We don't know the context hash of the imported module just yet. Let's postpone its creation until EndOfMainFile, where we iterate over DirectModularDeps that also contains this module. We can also use its presence in DirectModularDeps to determine that it was imported by the main file.

jansvoboda11 retitled this revision from [clang][deps] Stop assuming the TU's context hash to [clang][deps] NFC: Stop assuming the TU's context hash.May 14 2021, 5:08 AM
jansvoboda11 edited the summary of this revision. (Show Details)
jansvoboda11 edited the summary of this revision. (Show Details)
jansvoboda11 edited the summary of this revision. (Show Details)May 14 2021, 5:39 AM
jansvoboda11 added inline comments.
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
182

Computing the context hash might be expensive now, so use const Module * instead.

This revision is now accepted and ready to land.May 14 2021, 11:22 AM
This revision was landed with ongoing or failed builds.May 17 2021, 12:16 AM
This revision was automatically updated to reflect the committed changes.