This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules] Avoid re-exporting PCH imports on every later module import
ClosedPublic

Authored by benlangmuir on Apr 12 2023, 3:09 PM.

Details

Summary

We only want to make PCH imports visible once for the the TU, not repeatedly after every subsequent import. This causes some incorrect behaviour with submodule visibility, and causes us to get extra module dependencies in the scanner. So far I have only seen obviously incorrect behaviour when building with -fmodule-name to cause a submodule to be textually included when using the PCH, though the old behaviour seems wrong regardless.

rdar://107449644

Diff Detail

Event Timeline

benlangmuir created this revision.Apr 12 2023, 3:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 3:09 PM
benlangmuir requested review of this revision.Apr 12 2023, 3:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 3:09 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Can you explain why we need to keep separate PendingImportedModulesSema now? In what situation will it end up aggregating more than one PendingImportedModules?

Can you explain why we need to keep separate PendingImportedModulesSema now? In what situation will it end up aggregating more than one PendingImportedModules?

I don't know if this happens in practice, but I haven't been able to prove to myself that it cannot. I'm not sure there is much simplification we can get here regardless, because we still need some kind of state tracking here for the case when Sema is not provided until later. If we are sure it can never add more PendingImportedModules later, then a flag telling us whether we have handled these modules in PP (but not yet Sema) would be sufficient.

jansvoboda11 accepted this revision.Apr 20 2023, 10:47 AM

That makes sense to me, thanks!

This revision is now accepted and ready to land.Apr 20 2023, 10:47 AM
This revision was landed with ongoing or failed builds.Apr 20 2023, 11:30 AM
This revision was automatically updated to reflect the committed changes.