Files
TheRock/compiler/amd-llvm/clang/test/Modules/module-init-forcelly-loaded-module.cpp
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

84 lines
2.2 KiB
C++

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
// RUN: cd %t
//
// RUN: %clang_cc1 -fmodule-name=test -fno-cxx-modules -fmodule-map-file-home-is-cwd -xc++ -emit-module \
// RUN: -triple %itanium_abi_triple \
// RUN: -iquote . -fmodules -fno-implicit-modules %t/test.cppmap -o %t/test.pcm
// RUN: %clang_cc1 -fmodule-name=test2 -fno-cxx-modules -fmodule-map-file-home-is-cwd -xc++ -emit-module \
// RUN: -iquote . -fmodules -fno-implicit-modules %t/test2.cppmap -o %t/test2.pcm \
// RUN: -triple %itanium_abi_triple
// RUN: %clang_cc1 -fno-cxx-modules -fmodule-map-file-home-is-cwd -fmodules -fno-implicit-modules \
// RUN: -fmodule-file=%t/test.pcm -fmodule-file=%t/test2.pcm %t/test.cc \
// RUN: -triple %itanium_abi_triple \
// RUN: -emit-llvm -o - | FileCheck %t/test.cc
//--- common.h
#ifndef COMMON_H
#define COMMON_H
extern "C" void exit(int);
namespace namespace_foo {
class FooBar {};
namespace namespace_bar {
class RegisterOnce;
template <const FooBar&>
struct FooBarRegisterer {
static const RegisterOnce kRegisterOnce;
};
class RegisterOnce {};
void RegisterFooBarImpl();
template <const FooBar& t>
const RegisterOnce FooBarRegisterer<t>::kRegisterOnce =
(RegisterFooBarImpl(), RegisterOnce());
template <FooBar& tag,
const RegisterOnce& =
FooBarRegisterer<tag>::kRegisterOnce>
FooBar CreateFooBarInternal ;
}
template <FooBar& tag>
FooBar CreateFooBar(
int , int ,
int ) {
return namespace_bar::CreateFooBarInternal<tag>;
}
FooBar kNullArgumentFooBar =
CreateFooBar<kNullArgumentFooBar>(1, 0, 0);
namespace namespace_bar {
void RegisterFooBarImpl() {
static bool donealready = false;
if (donealready)
exit(1);
donealready = true;
}
}
}
#endif
//--- test.cc
int main() {}
// Check that we won't have multiple initializer by not calling RegisterFooBarImpl twice
// CHECK: call {{.*}}@_ZN13namespace_foo13namespace_bar18RegisterFooBarImplEv
// CHECK-NOT: call {{.*}}@_ZN13namespace_foo13namespace_bar18RegisterFooBarImplEv
//--- test.cppmap
module "test" {
header "test.h"
}
//--- test.h
#ifndef test
#include "common.h"
#endif
//--- test2.cppmap
module "test2" {
header "test2.h"
}
//--- test2.h
#ifndef test2
#include "common.h"
#endif