|
| 1 | +// RUN: rm -rf %t |
| 2 | +// RUN: split-file %s %t |
| 3 | +// RUN: cd %t |
| 4 | +// |
| 5 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -emit-module-interface \ |
| 6 | +// RUN: %t/Mod.cppm -o %t/Mod.pcm |
| 7 | +// |
| 8 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/Mod.pcm \ |
| 9 | +// RUN: -emit-llvm -o - | FileCheck %t/Mod.cppm |
| 10 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -fmodule-file=Mod=%t/Mod.pcm \ |
| 11 | +// RUN: %t/Use.cpp -emit-llvm -o - | FileCheck %t/Use.cpp |
| 12 | +// |
| 13 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -emit-module-interface \ |
| 14 | +// RUN: %t/Mod.cppm -o %t/Mod.pcm -DKEY_FUNCTION_INLINE |
| 15 | +// |
| 16 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/Mod.pcm \ |
| 17 | +// RUN: -emit-llvm -o - | FileCheck %t/Mod.cppm -check-prefix=CHECK-INLINE |
| 18 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -fmodule-file=Mod=%t/Mod.pcm \ |
| 19 | +// RUN: %t/Use.cpp -emit-llvm -o - | FileCheck %t/Use.cpp -check-prefix=CHECK-INLINE |
| 20 | +// |
| 21 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -emit-module-interface \ |
| 22 | +// RUN: %t/M-A.cppm -o %t/M-A.pcm |
| 23 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -fmodule-file=M:A=%t/M-A.pcm \ |
| 24 | +// RUN: %t/M-B.cppm -emit-llvm -o - | FileCheck %t/M-B.cppm |
| 25 | + |
| 26 | +//--- Mod.cppm |
| 27 | +export module Mod; |
| 28 | + |
| 29 | +export class Base { |
| 30 | +public: |
| 31 | + virtual ~Base(); |
| 32 | +}; |
| 33 | +#ifdef KEY_FUNCTION_INLINE |
| 34 | +inline |
| 35 | +#endif |
| 36 | +Base::~Base() {} |
| 37 | + |
| 38 | +// CHECK: @_ZTVW3Mod4Base = unnamed_addr constant |
| 39 | +// CHECK: @_ZTSW3Mod4Base = constant |
| 40 | +// CHECK: @_ZTIW3Mod4Base = constant |
| 41 | + |
| 42 | +// CHECK-INLINE: @_ZTVW3Mod4Base = linkonce_odr unnamed_addr constant |
| 43 | +// CHECK-INLINE: @_ZTSW3Mod4Base = linkonce_odr constant |
| 44 | +// CHECK-INLINE: @_ZTIW3Mod4Base = linkonce_odr constant |
| 45 | + |
| 46 | +module :private; |
| 47 | +int private_use() { |
| 48 | + Base base; |
| 49 | + return 43; |
| 50 | +} |
| 51 | + |
| 52 | +//--- Use.cpp |
| 53 | +import Mod; |
| 54 | +int use() { |
| 55 | + Base* base = new Base(); |
| 56 | + return 43; |
| 57 | +} |
| 58 | + |
| 59 | +// CHECK-NOT: @_ZTSW3Mod4Base = constant |
| 60 | +// CHECK-NOT: @_ZTIW3Mod4Base = constant |
| 61 | +// CHECK: @_ZTVW3Mod4Base = external unnamed_addr |
| 62 | + |
| 63 | +// CHECK-INLINE: @_ZTVW3Mod4Base = linkonce_odr unnamed_addr constant |
| 64 | +// CHECK-INLINE: @_ZTSW3Mod4Base = linkonce_odr constant |
| 65 | +// CHECK-INLINE: @_ZTIW3Mod4Base = linkonce_odr constant |
| 66 | + |
| 67 | +// Check the case that the declaration of the key function comes from another |
| 68 | +// module unit but the definition of the key function comes from the current |
| 69 | +// mdoule unit. |
| 70 | + |
| 71 | +//--- M-A.cppm |
| 72 | +export module M:A; |
| 73 | +export class C { |
| 74 | +public: |
| 75 | + virtual ~C(); |
| 76 | +}; |
| 77 | + |
| 78 | +int a_use() { |
| 79 | + C c; |
| 80 | + return 43; |
| 81 | +} |
| 82 | + |
| 83 | +//--- M-B.cppm |
| 84 | +export module M:B; |
| 85 | +import :A; |
| 86 | + |
| 87 | +C::~C() {} |
| 88 | + |
| 89 | +int b_use() { |
| 90 | + C c; |
| 91 | + return 43; |
| 92 | +} |
| 93 | + |
| 94 | +// CHECK: @_ZTVW1M1C = unnamed_addr constant |
| 95 | +// CHECK: @_ZTSW1M1C = constant |
| 96 | +// CHECK: @_ZTIW1M1C = constant |
0 commit comments