1 // Test case from https://github.com/llvm/llvm-project/issues/59999
5 // RUN: split-file %s %t
7 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/Module.cppm \
8 // RUN: -emit-module-interface -o %t/Module.pcm
9 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/Object.cppm \
10 // RUN: -fmodule-file=Module=%t/Module.pcm -emit-module-interface -o %t/Object.pcm
11 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/Object.pcm \
12 // RUN: -fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/Object.cppm
14 // Test again with reduced BMI.
17 // RUN: split-file %s %t
19 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/Module.cppm \
20 // RUN: -emit-reduced-module-interface -o %t/Module.pcm
21 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/Object.cppm \
22 // RUN: -fmodule-file=Module=%t/Module.pcm -emit-module-interface -o %t/Object.pcm
23 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/Object.pcm \
24 // RUN: -fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/Object.cppm
30 export template <class ObjectType> bool ModuleRegister() { return true; };
32 export struct ModuleEntry {
33 static const bool bRegistered;
36 const bool ModuleEntry::bRegistered = ModuleRegister<ModuleEntry>();
43 export template <class ObjectType> bool ObjectRegister() { return true; }
44 export struct NObject {
45 static const bool bRegistered;
47 export struct ObjectModuleEntry {
48 static const bool bRegistered;
51 // This function is also required for crash
52 const bool NObject::bRegistered = ObjectRegister<NObject>();
53 // One another function, that helps clang crash
54 const bool ObjectModuleEntry::bRegistered = ModuleRegister<ObjectModuleEntry>();
56 // Check that the LLVM IR is generated correctly instead of crashing.
57 // CHECK: define{{.*}}@_ZGIW6Object