This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules] Fix handling of `ModuleHeaderRole::ExcludedHeader`
ClosedPublic

Authored by jansvoboda11 on Oct 6 2022, 11:21 AM.

Details

Summary

This is a follow-up to D134224. The original patch added new ExcludedHeader enumerator to ModuleMap::ModuleHeaderRole and started associating headers with the modules they were excluded from. This was necessary to consider their module maps as "affecting" in certain situations and in turn serialize them into the PCM.

The association of the header and module needs to be handled when deserializing the PCM as well, though. This patch fixes a potential assertion failure and a regression. This essentially reverts parts of feb54b6ded123f8118fdc20620d3f657dfeab485.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Oct 6 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 11:21 AM
Herald added a subscriber: ributzka. · View Herald Transcript
jansvoboda11 requested review of this revision.Oct 6 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 11:21 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 added inline comments.Oct 6 2022, 11:26 AM
clang/lib/Lex/ModuleMap.cpp
598

This is what actually fixes the attached test case. MakeResult was too late to check for excluded headers (in the if (H.getModule()->getTopLevelModule() == SourceModule) condition) - we'd end up returning {} and skipping remaining module associations of the header file. This caused the ObjC interface to be associated with the wrong module in the PCM, causing "interface redefinition" errors.

This revision is now accepted and ready to land.Oct 6 2022, 3:28 PM