1 // RUN: rm -rf %t 2 // RUN: mkdir %t 3 4 // Check compiling a module interface to a .pcm file. 5 // 6 // RUN: %clang -std=c++2a -x c++-module --precompile %s -o %t/module.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE 7 // 8 // CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface 9 // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm 10 // CHECK-PRECOMPILE-SAME: -x c++ 11 // CHECK-PRECOMPILE-SAME: modules.cpp 12 13 // Check compiling a .pcm file to a .o file. 14 // 15 // RUN: %clang -std=c++2a %t/module.pcm -S -o %t/module.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-COMPILE 16 // 17 // CHECK-COMPILE: -cc1 {{.*}} {{-emit-obj|-S}} 18 // CHECK-COMPILE-SAME: -o {{.*}}module{{2*}}.pcm.o 19 // CHECK-COMPILE-SAME: -x pcm 20 // CHECK-COMPILE-SAME: {{.*}}.pcm 21 22 // Check use of a .pcm file in another compilation. 23 // 24 // RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE 25 // RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE 26 // 27 // CHECK-USE: -cc1 28 // CHECK-USE-SAME: {{-emit-obj|-S}} 29 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm 30 // CHECK-USE-SAME: -o {{.*}}.{{o|s}}{{"?}} {{.*}}-x c++ 31 // CHECK-USE-SAME: modules.cpp 32 33 // Check combining precompile and compile steps works. 34 // 35 // RUN: %clang -std=c++2a -x c++-module %s -S -o %t/module2.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE --check-prefix=CHECK-COMPILE 36 37 // Check that .cppm is treated as a module implicitly. 38 // 39 // RUN: cp %s %t/module.cppm 40 // RUN: %clang -std=c++2a --precompile %t/module.cppm -o %t/module.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE 41 42 // Check compiling a header unit to a .pcm file. 43 // 44 // RUN: echo '#define FOO BAR' > %t/foo.h 45 // RUN: %clang -std=c++2a --precompile -x c++-header %t/foo.h -fmodule-name=header -o %t/foo.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-HEADER-UNIT 46 // 47 // CHECK-HEADER-UNIT: -cc1 48 // CHECK-HEADER-UNIT-SAME: -emit-header-module 49 // CHECK-HEADER-UNIT-SAME: -fmodule-name=header 50 // CHECK-HEADER-UNIT-SAME: -o {{.*}}foo.pcm 51 // CHECK-HEADER-UNIT-SAME: -x c++-header 52 // CHECK-HEADER-UNIT-SAME: foo.h 53 54 // Check use of header unit. 55 // 56 // RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -fmodule-file=%t/foo.pcm -I%t -DIMPORT -Dexport= %s -E -o - -v 2>&1 | FileCheck %s --check-prefix=CHECK-HEADER-UNIT-USE 57 // 58 // CHECK-HEADER-UNIT-USE: -cc1 59 // CHECK-HEADER-UNIT-USE: -E 60 // CHECK-HEADER-UNIT-USE: -fmodule-file={{.*}}module.pcm 61 // CHECK-HEADER-UNIT-USE: -fmodule-file={{.*}}foo.pcm 62 63 // Note, we use -Dexport= to make this a module implementation unit when building the implementation. 64 export module foo; 65 66 #ifdef IMPORT 67 // CHECK-HEADER-UNIT-USE: FOO; 68 FOO; 69 70 // CHECK-HEADER-UNIT-USE: import header.{{.*}}foo.h{{.*}}; 71 import "foo.h"; 72 73 // CHECK-HEADER-UNIT-USE: BAR; 74 FOO; 75 #endif 76