| 1 |
// RUN: rm -rf %t |
| 2 |
// |
| 3 |
// First, create two modules a and b, with a dependency b -> a, both within |
| 4 |
// the same directory p1. |
| 5 |
// |
| 6 |
// RUN: mkdir -p %t/p1 |
| 7 |
// RUN: cd %t/p1 |
| 8 |
// |
| 9 |
// RUN: grep "<AM>" %s > %t/p1/a.modulemap |
| 10 |
// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \ |
| 11 |
// RUN: -fmodules-embed-all-files -fmodules-local-submodule-visibility \ |
| 12 |
// RUN: -fmodule-name="a" -o a.pcm a.modulemap |
| 13 |
// |
| 14 |
// RUN: grep "<BM>" %s > %t/p1/b.modulemap |
| 15 |
// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \ |
| 16 |
// RUN: -fmodules-embed-all-files -fmodules-local-submodule-visibility \ |
| 17 |
// RUN: -fmodule-name="b" -o b.pcm b.modulemap |
| 18 |
// |
| 19 |
// Next, move the whole tree p1 -> p2. |
| 20 |
// |
| 21 |
// RUN: cd %t |
| 22 |
// RUN: mv %t/p1 %t/p2 |
| 23 |
// RUN: cd %t/p2 |
| 24 |
// |
| 25 |
// Compile a new module c in the newly generated tree that depends on b; c.pcm |
| 26 |
// has to be within a subdirectory so a.modulemap will be one step up (../) from |
| 27 |
// c.pcm. |
| 28 |
// |
| 29 |
// RUN: mkdir %t/p2/c |
| 30 |
// RUN: grep "<CM>" %s > %t/p2/c/c.modulemap |
| 31 |
// RUN: grep "<CH>" %s > %t/p2/c/c.h |
| 32 |
// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \ |
| 33 |
// RUN: -fmodules-embed-all-files -fmodules-local-submodule-visibility \ |
| 34 |
// RUN: -fmodule-name="c" -fmodule-file=b.pcm -o c/c.pcm c/c.modulemap |
| 35 |
// |
| 36 |
// Delete a.modulemap from its original location, and instead inject a different |
| 37 |
// (unrelated) a.modulemap in the path p2/p2. |
| 38 |
// |
| 39 |
// RUN: rm %t/p2/a.modulemap |
| 40 |
// RUN: mkdir -p %t/p2/p2 |
| 41 |
// RUN: touch %t/p2/p2/a.modulemap |
| 42 |
// |
| 43 |
// Now compile a file c.cpp that uses c.h and the module c; it is important |
| 44 |
// to first load b.pcm and a.pcm before c.pcm on the command line to trigger |
| 45 |
// the right order of module loading. This used to trigger clang to find the |
| 46 |
// p2/p2/a.modulemap via the path c/../p2/a.modulemap, which is not the correct |
| 47 |
// relative path from c. |
| 48 |
// |
| 49 |
// RUN: grep "<CC>" %s > %t/p2/c/c.cpp |
| 50 |
// RUN: %clang_cc1 -I. -x c++ -fmodules \ |
| 51 |
// RUN: -fmodule-file=b.pcm -fmodule-file=a.pcm -fmodule-file=c/c.pcm \ |
| 52 |
// RUN: -o c/c.o -emit-obj c/c.cpp |
| 53 |
|
| 54 |
module "a" { // <AM> |
| 55 |
} // <AM> |
| 56 |
|
| 57 |
module "b" { // <BM> |
| 58 |
use "a" // <BM> |
| 59 |
} // <BM> |
| 60 |
|
| 61 |
module "c" { // <CM> |
| 62 |
header "c/c.h" // <CM> |
| 63 |
use "a" // <CM> |
| 64 |
use "b" // <CM> |
| 65 |
} // <CM> |
| 66 |
|
| 67 |
inline void c() {} // <CH> |
| 68 |
|
| 69 |
#include "c/c.h" // <CC> |
| 70 |
void foo() { c(); } // <CC> |