1// RUN: rm -rf %t && mkdir %t
2// RUN: split-file %s %t
3
4//--- a.modulemap
5module a {}
6
7//--- b.modulemap
8module b {}
9
10//--- test-simple.m
11// expected-no-diagnostics
12@import a;
13
14// Build without b.modulemap:
15//
16// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -fdisable-module-hash \
17// RUN:   -fmodule-map-file=%t/a.modulemap %t/test-simple.m -verify
18// RUN: mv %t/cache %t/cache-without-b
19
20// Build with b.modulemap:
21//
22// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -fdisable-module-hash \
23// RUN:   -fmodule-map-file=%t/a.modulemap -fmodule-map-file=%t/b.modulemap %t/test-simple.m -verify
24// RUN: mv %t/cache %t/cache-with-b
25
26// Neither PCM file considers 'b.modulemap' an input:
27//
28// RUN: %clang_cc1 -module-file-info %t/cache-without-b/a.pcm | FileCheck %s --check-prefix=CHECK-B
29// RUN: %clang_cc1 -module-file-info %t/cache-with-b/a.pcm | FileCheck %s --check-prefix=CHECK-B
30// CHECK-B-NOT: Input file: {{.*}}b.modulemap
31
32//--- c.modulemap
33module c [no_undeclared_includes] { header "c.h" }
34
35//--- c.h
36#if __has_include("d.h") // This should use 'd.modulemap' in order to determine that 'd.h'
37                         // doesn't exist for 'c' because of its '[no_undeclared_includes]'.
38#endif
39
40//--- d.modulemap
41module d { header "d.h" }
42
43//--- d.h
44// empty
45
46//--- test-no-undeclared-includes.m
47// expected-no-diagnostics
48@import c;
49
50// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fdisable-module-hash \
51// RUN:   -fmodule-map-file=%t/c.modulemap -fmodule-map-file=%t/d.modulemap \
52// RUN:   %t/test-no-undeclared-includes.m -verify
53
54// The PCM file considers 'd.modulemap' an input because it affects the compilation,
55// although it doesn't describe the built module or its imports.
56//
57// RUN: %clang_cc1 -module-file-info %t/cache/c.pcm | FileCheck %s --check-prefix=CHECK-D
58// CHECK-D: Input file: {{.*}}d.modulemap
59