This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules][deps] Parse "FW_Private" module map even after loading "FW" PCM
ClosedPublic

Authored by jansvoboda11 on May 12 2023, 1:41 PM.

Details

Summary

When Clang loads a PCM that depends on another PCM describing framework module "FW", ModuleMap registers "FW" as known, without seeing the module map that defines it (or the adjacent "FW_Private" module map). Later, when looking at a header from "FW_Private", ModuleMap returns early due to having knowledge about "FW" and never associates that header with "FW_Private", leading to it being treated as textual. This behavior is caused by D150292, where the scanner stops calling HeaderSearch::lookupModule() eagerly for every loaded PCM.

This patch skips an early check when trying to figure out the framework module for a header, which ensures the "FW" and (most importantly) "FW_Private" module maps can be parsed even after loading "FW" from a PCM. Note that the HeaderSearch::loadModuleMapFile() function we not call unconditionally has caching behavior of its own, meaning it will avoid parsing module map file repeatedly.

Depends on D150320.

Diff Detail

Event Timeline

jansvoboda11 created this revision.May 12 2023, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2023, 1:41 PM
Herald added a subscriber: ributzka. · View Herald Transcript
jansvoboda11 requested review of this revision.May 12 2023, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2023, 1:41 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 added inline comments.May 12 2023, 1:44 PM
clang/lib/Lex/HeaderSearch.cpp
1795

We should probably break for LMM_AlreadyLoaded instead of returning null.

jansvoboda11 edited the summary of this revision. (Show Details)May 12 2023, 1:50 PM
benlangmuir accepted this revision.May 15 2023, 11:25 AM

LGTM. I ran into a similar issue in a downstream branch

This revision is now accepted and ready to land.May 15 2023, 11:25 AM

Expose new preprocessor option as a -cc1 flag, move test from ClangScanDeps to Modules directory.

This revision was landed with ongoing or failed builds.Jul 17 2023, 1:51 PM
This revision was automatically updated to reflect the committed changes.