Skip to content

Commit 9165d60

Browse files
committed
[clang][modules] Allow module map files with textual header be non-affecting
1 parent 3ea5dff commit 9165d60

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
187187
continue;
188188

189189
const HeaderFileInfo *HFI = HS.getExistingLocalFileInfo(*File);
190-
if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
190+
if (!HFI || ((HFI->isModuleHeader || HFI->isTextualModuleHeader) &&
191+
!HFI->isCompilingModuleHeader))
191192
continue;
192193

193194
for (const auto &KH : HS.findResolvedModulesForHeader(*File)) {
@@ -2055,11 +2056,12 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
20552056

20562057
// Get the file info. Skip emitting this file if we have no information on
20572058
// it as a header file (in which case HFI will be null) or if it hasn't
2058-
// changed since it was loaded. Also skip it if it's for a modular header
2059-
// from a different module; in that case, we rely on the module(s)
2059+
// changed since it was loaded. Also skip it if it's for a non-excluded
2060+
// header from a different module; in that case, we rely on the module(s)
20602061
// containing the header to provide this information.
20612062
const HeaderFileInfo *HFI = HS.getExistingLocalFileInfo(*File);
2062-
if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
2063+
if (!HFI || ((HFI->isModuleHeader || HFI->isTextualModuleHeader) &&
2064+
!HFI->isCompilingModuleHeader))
20632065
continue;
20642066

20652067
// Massage the file path into an appropriate form.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This test checks that a module map with a textual header can be marked as
2+
// non-affecting.
3+
4+
// RUN: rm -rf %t && mkdir %t
5+
// RUN: split-file %s %t
6+
7+
//--- A.modulemap
8+
module A { textual header "A.h" }
9+
//--- B.modulemap
10+
module B { header "B.h" export * }
11+
//--- A.h
12+
typedef int A_int;
13+
//--- B.h
14+
#include "A.h"
15+
typedef A_int B_int;
16+
17+
// RUN: %clang_cc1 -fmodules -emit-module %t/A.modulemap -fmodule-name=A -o %t/A.pcm \
18+
// RUN: -fmodule-map-file=%t/A.modulemap -fmodule-map-file=%t/B.modulemap
19+
20+
// RUN: %clang_cc1 -fmodules -emit-module %t/B.modulemap -fmodule-name=B -o %t/B0.pcm \
21+
// RUN: -fmodule-map-file=%t/A.modulemap -fmodule-map-file=%t/B.modulemap -fmodule-file=%t/A.pcm
22+
23+
// RUN: %clang_cc1 -fmodules -emit-module %t/B.modulemap -fmodule-name=B -o %t/B1.pcm \
24+
// RUN: -fmodule-map-file=%t/B.modulemap -fmodule-file=%t/A.pcm
25+
26+
// RUN: diff %t/B0.pcm %t/B1.pcm

0 commit comments

Comments
 (0)