| 1 |
// https://github.com/llvm/llvm-project/issues/59765 |
| 2 |
// FIXME: Since the signature of the constructors/destructors is |
| 3 |
// different in different targets. The current CHECK can't work |
| 4 |
// well when targeting AIX and z/OS. |
| 5 |
// It would be better to add the corresponding test for other test. |
| 6 |
// UNSUPPORTED: system-aix |
| 7 |
// UNSUPPORTED: target={{.*}}-zos{{.*}} |
| 8 |
// |
| 9 |
// RUN: rm -rf %t |
| 10 |
// RUN: mkdir %t |
| 11 |
// RUN: split-file %s %t |
| 12 |
// |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/M.cppm -triple %itanium_abi_triple -emit-module-interface -o %t/M.pcm |
| 14 |
// RUN: %clang_cc1 -std=c++20 %t/M.pcm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/M.cppm |
| 15 |
// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/Use.cpp |
| 16 |
// |
| 17 |
// Check that the behavior of header units is normal as headers. |
| 18 |
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header %t/foo.h -emit-header-unit -o %t/foo.pcm |
| 19 |
// RUN: %clang_cc1 -std=c++20 %t/UseHU.cpp -fmodule-file=%t/foo.pcm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/UseHU.cpp |
| 20 |
|
| 21 |
//--- M.cppm |
| 22 |
export module M; |
| 23 |
export class A { |
| 24 |
public: |
| 25 |
A(); |
| 26 |
~A(); |
| 27 |
void use(); |
| 28 |
}; |
| 29 |
export A a; |
| 30 |
|
| 31 |
// CHECK: @_ZW1M1a = {{.*}}global %class.A zeroinitializer |
| 32 |
// CHECK: define{{.*}}void @__cxx_global_var_init() |
| 33 |
// CHECK-NEXT: entry: |
| 34 |
// CHECK-NEXT: call{{.*}}@_ZNW1M1AC1Ev({{.*}}@_ZW1M1a |
| 35 |
// CHECK-NEXT: call{{.*}}@__cxa_atexit(ptr @_ZNW1M1AD1Ev, ptr @_ZW1M1a |
| 36 |
|
| 37 |
//--- Use.cpp |
| 38 |
import M; |
| 39 |
void use() { |
| 40 |
a.use(); |
| 41 |
} |
| 42 |
|
| 43 |
// CHECK-NOT: @_ZNW1M1AC1Ev |
| 44 |
// CHECK-NOT: @_ZNW1M1AD1Ev |
| 45 |
|
| 46 |
//--- foo.h |
| 47 |
class A { |
| 48 |
public: |
| 49 |
A(); |
| 50 |
~A(); |
| 51 |
void use(); |
| 52 |
}; |
| 53 |
A a; |
| 54 |
|
| 55 |
//--- UseHU.cpp |
| 56 |
import "foo.h"; |
| 57 |
void use() { |
| 58 |
a.use(); |
| 59 |
} |
| 60 |
|
| 61 |
// CHECK: @a = {{.*}}global %class.A zeroinitializer |
| 62 |
// CHECK: define{{.*}}void @__cxx_global_var_init() |
| 63 |
// CHECK-NEXT: entry: |
| 64 |
// CHECK-NEXT: call{{.*}}@_ZN1AC1Ev({{.*}}@a |
| 65 |
// CHECK-NEXT: call{{.*}}@__cxa_atexit(ptr @_ZN1AD1Ev, ptr @a |