Debian Codegraph @

clang/test/Driver/module-output.cppm

raw
1 // It is annoying to handle different slash direction
2 // in Windows and Linux. So we disable the test on Windows
3 // here.
4 // REQUIRES: !system-windows
5 // On AIX, the default output for `-c` may be `.s` instead of `.o`,
6 // which makes the test fail. So disable the test on AIX.
7 // REQUIRES: !system-aix
8 //
9 // RUN: rm -rf %t
10 // RUN: mkdir %t
11 // RUN: split-file %s %t
12 //
13 // Tests that the .pcm file will be generated in the same directory with the specified
14 // output and the name of the .pcm file should be the same with the input file.
15 // RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -c -o %t/output/Hello.o \
16 // RUN: -fno-modules-reduced-bmi -### 2>&1 | FileCheck %t/Hello.cppm
17 //
18 // Tests that the output file will be generated in the input directory if the output
19 // file is not the corresponding object file.
20 // RUN: %clang -std=c++20 %t/Hello.cppm %t/AnotherModule.cppm -fmodule-output -o \
21 // RUN: %t/output/a.out -fno-modules-reduced-bmi -### 2>&1 | FileCheck %t/AnotherModule.cppm
22 //
23 // Tests that clang will reject the command line if it specifies -fmodule-output with
24 // multiple archs.
25 // RUN: not %clang %t/Hello.cppm -fmodule-output -arch i386 -arch x86_64 -### \
26 // RUN: -fno-modules-reduced-bmi --target=x86_64-apple-darwin 2>&1 | FileCheck %t/Hello.cppm \
27 // RUN: -check-prefix=MULTIPLE-ARCH
28
29 // Tests that the .pcm file will be generated in the same path with the specified one
30 // in the comamnd line.
31 // RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/pcm/Hello.pcm -o %t/Hello.o \
32 // RUN: -fno-modules-reduced-bmi -c -### 2>&1 | FileCheck %t/Hello.cppm --check-prefix=CHECK-SPECIFIED
33 //
34 // RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/Hello.pcm -fmodule-output -c -fsyntax-only \
35 // RUN: -fno-modules-reduced-bmi -### 2>&1 | FileCheck %t/Hello.cppm --check-prefix=CHECK-NOT-USED
36
37 // Test that we can emit a warning if the type of the input file is not a module interface unit.
38 // RUN: %clang -std=c++20 %t/a.cpp -fmodule-output -fno-modules-reduced-bmi -c -o %t/a.o -### 2>&1 | FileCheck %t/a.cpp
39
40 //--- Hello.cppm
41 export module Hello;
42
43 // CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/output/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm"
44 // CHECK: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/output/Hello.o" "-x" "pcm" "{{.*}}/output/Hello.pcm"
45 // CHECK-CWD: -fmodule-output={{.*}}/build/Hello.pcm
46 // MULTIPLE-ARCH: option '-fmodule-output' cannot be used with multiple arch options
47
48 // CHECK-SPECIFIED: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/pcm/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm"
49 // CHECK-SPECIFIED: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello.o" "-x" "pcm" "{{.*}}/pcm/Hello.pcm"
50
51 // CHECK-NOT-USED-NOT: warning: argument unused during compilation: '-fmodule-output'
52 // CHECK-NOT-USED-NOT: warning: argument unused during compilation: '-fmodule-output=Hello.pcm'
53 // CHECK-NOT-USED-NOT: "-fmodule-output"
54 // CHECK-NOT-USED-NOT: "-fmodule-output="
55
56 //--- AnotherModule.cppm
57 export module AnotherModule;
58 // CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm"
59 // CHECK: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello-{{.*}}.o" "-x" "pcm" "{{.*}}/Hello.pcm"
60 // CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "AnotherModule.cppm" {{.*}}"-o" "{{.*}}/AnotherModule.pcm" "-x" "c++" "{{.*}}/AnotherModule.cppm"
61 // CHECK: "-emit-obj" {{.*}}"-main-file-name" "AnotherModule.cppm" {{.*}}"-o" "{{.*}}/AnotherModule-{{.*}}.o" "-x" "pcm" "{{.*}}/AnotherModule.pcm"
62
63 //--- a.cpp
64 export module a;
65
66 // CHECK: warning: argument unused during compilation: '-fmodule-output'