| // RUN: rm -rf %t | |
| // RUN: mkdir -p %t | |
| // RUN: split-file %s %t | |
| // | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm \ | |
| // RUN: -emit-reduced-module-interface -o %t/a.pcm | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \ | |
| // RUN: -fmodule-file=a=%t/a.pcm -emit-reduced-module-interface -o %t/b.pcm | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/main.cpp \ | |
| // RUN: -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ | |
| // RUN: -emit-llvm -o - | FileCheck %t/main.cpp | |
| // | |
| // Also test with full BMI for parity. | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm \ | |
| // RUN: -emit-module-interface -o %t/a.full.pcm | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \ | |
| // RUN: -fmodule-file=a=%t/a.full.pcm -emit-module-interface -o %t/b.full.pcm | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/main.cpp \ | |
| // RUN: -fmodule-file=a=%t/a.full.pcm -fmodule-file=b=%t/b.full.pcm \ | |
| // RUN: -emit-llvm -o - | FileCheck %t/main.cpp | |
| // | |
| // Verify that an already-declared upstream subobject destructor without lazy | |
| // updates does not force its module into TouchedTopLevelModules. | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/m1.cppm \ | |
| // RUN: -emit-reduced-module-interface -o %t/m1.pcm | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/m2.cppm \ | |
| // RUN: -fmodule-file=m1=%t/m1.pcm -emit-reduced-module-interface -o %t/m2.pcm | |
| // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/m3.cppm \ | |
| // RUN: -fmodule-file=m1=%t/m1.pcm -fmodule-file=m2=%t/m2.pcm \ | |
| // RUN: -emit-reduced-module-interface -o %t/m3.pcm | |
| // RUN: %clang_cc1 -module-file-info %t/m3.pcm \ | |
| // RUN: -fmodule-file=m1=%t/m1.pcm -fmodule-file=m2=%t/m2.pcm \ | |
| // RUN: | FileCheck %t/m3.cppm --check-prefix=CHECK-M3 | |
| //--- a.cppm | |
| export module a; | |
| template <typename T> | |
| struct Inner { | |
| constexpr ~Inner() {} | |
| }; | |
| template <typename T> | |
| struct Outer { | |
| Inner<T> x; | |
| }; | |
| export template <typename T> | |
| struct Cache { | |
| Outer<T> x; | |
| }; | |
| export template <typename T> | |
| struct BaseCache { | |
| Outer<T> x; | |
| }; | |
| export template <typename T> | |
| struct VBaseCache { | |
| Outer<T> x; | |
| }; | |
| export template <typename T> | |
| struct ArrCache { | |
| Outer<T> x; | |
| }; | |
| export struct Assets { | |
| Cache<int> x; | |
| }; | |
| export struct ComplexAssets : BaseCache<int>, virtual VBaseCache<int> { | |
| ArrCache<int> arr[2]; | |
| }; | |
| export template <typename T> | |
| struct Holder { | |
| Cache<T> x; | |
| constexpr ~Holder() {} | |
| }; | |
| export constexpr auto holder_size = sizeof(Holder<int>); | |
| //--- b.cppm | |
| export module b; | |
| import a; | |
| export inline void touch(Assets *a) { delete a; } | |
| export inline void touch_complex(ComplexAssets *c) { delete c; } | |
| export inline void touch_holder(Holder<int> *h) { delete h; } | |
| //--- main.cpp | |
| import a; | |
| import b; | |
| constexpr bool test_constexpr() { | |
| Assets a{}; | |
| Holder<int> h{}; | |
| return true; | |
| } | |
| static_assert(test_constexpr()); | |
| void f(Assets *a, ComplexAssets *c, Holder<int> *h) { | |
| delete a; | |
| delete c; | |
| delete h; | |
| } | |
| // CHECK-DAG: define {{.*}}@_ZNW1a6AssetsD2Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a5CacheIiED2Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a13ComplexAssetsD1Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a13ComplexAssetsD2Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a9BaseCacheIiED2Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a10VBaseCacheIiED2Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a8ArrCacheIiED2Ev( | |
| // CHECK-DAG: define {{.*}}@_ZNW1a6HolderIiED2Ev( | |
| //--- m1.cppm | |
| export module m1; | |
| export struct Leaf { | |
| ~Leaf(); | |
| }; | |
| //--- m2.cppm | |
| export module m2; | |
| import m1; | |
| export struct Mid { | |
| Leaf l; | |
| }; | |
| //--- m3.cppm | |
| export module m3; | |
| import m2; | |
| export inline void destroy_mid(Mid *p) { delete p; } | |
| // CHECK-M3: Imports module 'm2': | |
| // CHECK-M3-NOT: Imports module 'm1': |