From 461a67fa15370a9ec88f8f8a240bf7c123bb2029 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:11:37 +0000 Subject: Vendor import of clang trunk r321017: https://llvm.org/svn/llvm-project/cfe/trunk@321017 --- test/Modules/path-resolution.modulemap | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/Modules/path-resolution.modulemap (limited to 'test/Modules/path-resolution.modulemap') diff --git a/test/Modules/path-resolution.modulemap b/test/Modules/path-resolution.modulemap new file mode 100644 index 0000000000000..72f5f142c3266 --- /dev/null +++ b/test/Modules/path-resolution.modulemap @@ -0,0 +1,70 @@ +// RUN: rm -rf %t +// +// First, create two modules a and b, with a dependency b -> a, both within +// the same directory p1. +// +// RUN: mkdir -p %t/p1 +// RUN: cd %t/p1 +// +// RUN: grep "" %s > %t/p1/a.modulemap +// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \ +// RUN: -fmodules-embed-all-files -fmodules-local-submodule-visibility \ +// RUN: -fmodule-name="a" -o a.pcm a.modulemap +// +// RUN: grep "" %s > %t/p1/b.modulemap +// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \ +// RUN: -fmodules-embed-all-files -fmodules-local-submodule-visibility \ +// RUN: -fmodule-name="b" -o b.pcm b.modulemap +// +// Next, move the whole tree p1 -> p2. +// +// RUN: cd %t +// RUN: mv %t/p1 %t/p2 +// RUN: cd %t/p2 +// +// Compile a new module c in the newly generated tree that depends on b; c.pcm +// has to be within a subdirectory so a.modulemap will be one step up (../) from +// c.pcm. +// +// RUN: mkdir %t/p2/c +// RUN: grep "" %s > %t/p2/c/c.modulemap +// RUN: grep "" %s > %t/p2/c/c.h +// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \ +// RUN: -fmodules-embed-all-files -fmodules-local-submodule-visibility \ +// RUN: -fmodule-name="c" -fmodule-file=b.pcm -o c/c.pcm c/c.modulemap +// +// Delete a.modulemap from its original location, and instead inject a different +// (unrelated) a.modulemap in the path p2/p2. +// +// RUN: rm %t/p2/a.modulemap +// RUN: mkdir -p %t/p2/p2 +// RUN: touch %t/p2/p2/a.modulemap +// +// Now compile a file c.cpp that uses c.h and the module c; it is important +// to first load b.pcm and a.pcm before c.pcm on the command line to trigger +// the right order of module loading. This used to trigger clang to find the +// p2/p2/a.modulemap via the path c/../p2/a.modulemap, which is not the correct +// relative path from c. +// +// RUN: grep "" %s > %t/p2/c/c.cpp +// RUN: %clang_cc1 -I. -x c++ -fmodules \ +// RUN: -fmodule-file=b.pcm -fmodule-file=a.pcm -fmodule-file=c/c.pcm \ +// RUN: -o c/c.o -emit-obj c/c.cpp + +module "a" { // +} // + +module "b" { // + use "a" // +} // + +module "c" { // + header "c/c.h" // + use "a" // + use "b" // +} // + +inline void c() {} // + +#include "c/c.h" // +void foo() { c(); } // -- cgit v1.3