llvm-project/clang/test/Modules/no-check-relocated-fw-private.c
Jan Svoboda be014563f2 [clang][modules][deps] Parse "FW_Private" module map even after loading "FW" PCM
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.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D150478
2023-07-17 13:50:24 -07:00

24 lines
992 B
C

// RUN: rm -rf %t
// RUN: split-file %s %t
//--- frameworks1/FW1.framework/Modules/module.modulemap
framework module FW1 { header "FW1.h" }
//--- frameworks1/FW1.framework/Headers/FW1.h
#import <FW2/FW2.h>
//--- frameworks2/FW2.framework/Modules/module.modulemap
framework module FW2 { header "FW2.h" }
//--- frameworks2/FW2.framework/Modules/module.private.modulemap
framework module FW2_Private { header "FW2_Private.h" }
//--- frameworks2/FW2.framework/Headers/FW2.h
//--- frameworks2/FW2.framework/PrivateHeaders/FW2_Private.h
//--- tu.c
#import <FW1/FW1.h> // expected-remark{{importing module 'FW1'}} \
// expected-remark{{importing module 'FW2'}}
#import <FW2/FW2_Private.h> // expected-remark{{importing module 'FW2_Private'}}
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fimplicit-module-maps \
// RUN: -F %t/frameworks1 -F %t/frameworks2 -fsyntax-only %t/tu.c \
// RUN: -fno-modules-check-relocated -Rmodule-import -verify