Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++20] [Modules] Missing vtable for explicit template instantiation in other units #123719

Closed
ChuanqiXu9 opened this issue Jan 21, 2025 · 1 comment · Fixed by #123871
Closed
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@ChuanqiXu9
Copy link
Member

Reproducer:

// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/a.cc -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm -emit-llvm -o - | FileCheck %t/a.cc
//
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-reduced-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/a.cc -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm -emit-llvm -o - | FileCheck %t/a.cc

//--- a.cppm
export module a;
class base {
public:
    ~base() = default;
    virtual void foo();
};

template <class T>
class a : public base {
public:
    virtual void foo() override;
};

extern template class a<int>;

//--- a.cc
module a:impl;
import a;

template <class T>
void a<T>::foo() {}

template class a<int>;
// CHECK: _ZTVW1a1aIiE
@ChuanqiXu9 ChuanqiXu9 added the clang:modules C++20 modules and Clang Header Modules label Jan 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 21, 2025

@llvm/issue-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)

Reproducer:
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/a.cc -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm -emit-llvm -o - | FileCheck %t/a.cc
//
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-reduced-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/a.cc -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm -emit-llvm -o - | FileCheck %t/a.cc

//--- a.cppm
export module a;
class base {
public:
    ~base() = default;
    virtual void foo();
};

template &lt;class T&gt;
class a : public base {
public:
    virtual void foo() override;
};

extern template class a&lt;int&gt;;

//--- a.cc
module a:impl;
import a;

template &lt;class T&gt;
void a&lt;T&gt;::foo() {}

template class a&lt;int&gt;;
// CHECK: _ZTVW1a1aIiE

ChuanqiXu9 added a commit to ChuanqiXu9/llvm-project that referenced this issue Jan 22, 2025
instantiation definition

Close llvm#123719

The reason is, we thought the external explicit template
instantiation declaration as the external definition incorrectly.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this issue Jan 22, 2025
…cit template instantiation definition (#123871)

Close llvm/llvm-project#123719

The reason is, we thought the external explicit template instantiation
declaration as the external definition incorrectly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
2 participants