| 1 |
// Test generation and import of user and system C++20 Header Units. |
| 2 |
|
| 3 |
// RUN: rm -rf %t |
| 4 |
// RUN: mkdir -p %t |
| 5 |
// RUN: split-file %s %t |
| 6 |
// RUN: cd %t |
| 7 |
|
| 8 |
// check user path |
| 9 |
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -I user \ |
| 10 |
// RUN: -xc++-user-header hu-01.h -o hu-01.pcm |
| 11 |
|
| 12 |
// RUN: %clang_cc1 -std=c++20 -module-file-info hu-01.pcm | \ |
| 13 |
// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t |
| 14 |
|
| 15 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface imp-hu-01.cpp \ |
| 16 |
// RUN: -I user -fmodule-file=hu-01.pcm -o B.pcm -Rmodule-import \ |
| 17 |
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t |
| 18 |
|
| 19 |
// check system path |
| 20 |
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -isystem system \ |
| 21 |
// RUN: -xc++-system-header hu-02.h -o hu-02.pcm |
| 22 |
|
| 23 |
// RUN: %clang_cc1 -std=c++20 -module-file-info hu-02.pcm | \ |
| 24 |
// RUN: FileCheck --check-prefix=CHECK-HU2 %s -DTDIR=%t |
| 25 |
|
| 26 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface imp-hu-02.cpp \ |
| 27 |
// RUN: -isystem system -fmodule-file=hu-02.pcm -o C.pcm \ |
| 28 |
// RUN: -Rmodule-import 2>&1 | \ |
| 29 |
// RUN: FileCheck --check-prefix=CHECK-SYS-IMP %s -DTDIR=%t |
| 30 |
|
| 31 |
// check absolute path |
| 32 |
// RUN: %clang_cc1 -std=c++20 -emit-header-unit \ |
| 33 |
// RUN: -xc++-header-unit-header %t/hu-03.h -o hu-03.pcm |
| 34 |
|
| 35 |
// RUN: %clang_cc1 -std=c++20 -module-file-info hu-03.pcm | \ |
| 36 |
// RUN: FileCheck --check-prefix=CHECK-HU3 %s -DTDIR=%t |
| 37 |
|
| 38 |
//--- user/hu-01.h |
| 39 |
int foo(int); |
| 40 |
|
| 41 |
// CHECK-HU: ====== C++20 Module structure ====== |
| 42 |
// CHECK-HU-NEXT: Header Unit 'user{{[/\\]}}hu-01.h' is the Primary Module at index #1 |
| 43 |
|
| 44 |
//--- imp-hu-01.cpp |
| 45 |
export module B; |
| 46 |
import "hu-01.h"; |
| 47 |
|
| 48 |
int bar(int x) { |
| 49 |
return foo(x); |
| 50 |
} |
| 51 |
// CHECK-IMP: remark: importing module 'user{{[/\\]}}hu-01.h' from 'hu-01.pcm' |
| 52 |
// expected-no-diagnostics |
| 53 |
|
| 54 |
//--- system/hu-02.h |
| 55 |
int baz(int); |
| 56 |
|
| 57 |
// CHECK-HU2: ====== C++20 Module structure ====== |
| 58 |
// CHECK-HU2-NEXT: Header Unit 'system{{[/\\]}}hu-02.h' is the Primary Module at index #1 |
| 59 |
|
| 60 |
//--- imp-hu-02.cpp |
| 61 |
module; |
| 62 |
import <hu-02.h>; |
| 63 |
|
| 64 |
export module C; |
| 65 |
|
| 66 |
int bar(int x) { |
| 67 |
return baz(x); |
| 68 |
} |
| 69 |
// CHECK-SYS-IMP: remark: importing module 'system{{[/\\]}}hu-02.h' from 'hu-02.pcm' |
| 70 |
// expected-no-diagnostics |
| 71 |
|
| 72 |
//--- hu-03.h |
| 73 |
int curly(int); |
| 74 |
|
| 75 |
// CHECK-HU3: ====== C++20 Module structure ====== |
| 76 |
// CHECK-HU3-NEXT: Header Unit '[[TDIR]]/hu-03.h' is the Primary Module at index #1 |
| 77 |
// expected-no-diagnostics |