1// Test case from https://github.com/llvm/llvm-project/issues/59999 2// 3// RUN: rm -rf %t 4// RUN: mkdir -p %t 5// RUN: split-file %s %t 6// 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 13 14// Test again with reduced BMI. 15// RUN: rm -rf %t 16// RUN: mkdir -p %t 17// RUN: split-file %s %t 18// 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 25 26 27//--- Module.cppm 28export module Module; 29 30export template <class ObjectType> bool ModuleRegister() { return true; }; 31 32export struct ModuleEntry { 33 static const bool bRegistered; 34}; 35 36const bool ModuleEntry::bRegistered = ModuleRegister<ModuleEntry>(); 37 38//--- Object.cppm 39export module Object; 40 41import Module; 42 43export template <class ObjectType> bool ObjectRegister() { return true; } 44export struct NObject { 45 static const bool bRegistered; 46}; 47export struct ObjectModuleEntry { 48 static const bool bRegistered; 49}; 50 51// This function is also required for crash 52const bool NObject::bRegistered = ObjectRegister<NObject>(); 53// One another function, that helps clang crash 54const bool ObjectModuleEntry::bRegistered = ModuleRegister<ObjectModuleEntry>(); 55 56// Check that the LLVM IR is generated correctly instead of crashing. 57// CHECK: define{{.*}}@_ZGIW6Object 58