xref: /aosp_15_r20/external/clang/test/CodeGenCXX/microsoft-abi-extern-template.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fno-rtti-data -O1 -disable-llvm-optzns %s -emit-llvm -o - -triple x86_64-windows-msvc | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li // Even though Foo<int> has an extern template declaration, we have to emit our
4*67e74705SXin Li // own copy the vftable when emitting the available externally constructor.
5*67e74705SXin Li 
6*67e74705SXin Li // CHECK: @"\01??_7?$Foo@H@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [
7*67e74705SXin Li // CHECK-SAME:   i8* bitcast (i8* (%struct.Foo*, i32)* @"\01??_G?$Foo@H@@UEAAPEAXI@Z" to i8*)
8*67e74705SXin Li // CHECK-SAME: ], comdat
9*67e74705SXin Li 
10*67e74705SXin Li // CHECK-LABEL: define %struct.Foo* @"\01?f@@YAPEAU?$Foo@H@@XZ"()
11*67e74705SXin Li // CHECK: call %struct.Foo* @"\01??0?$Foo@H@@QEAA@XZ"(%struct.Foo* %{{.*}})
12*67e74705SXin Li 
13*67e74705SXin Li // CHECK: define available_externally %struct.Foo* @"\01??0?$Foo@H@@QEAA@XZ"(%struct.Foo* returned %this)
14*67e74705SXin Li // CHECK:   store {{.*}} @"\01??_7?$Foo@H@@6B@"
15*67e74705SXin Li 
16*67e74705SXin Li // CHECK: define linkonce_odr i8* @"\01??_G?$Foo@H@@UEAAPEAXI@Z"(%struct.Foo* %this, i32 %should_call_delete)
17*67e74705SXin Li 
18*67e74705SXin Li struct Base {
19*67e74705SXin Li   virtual ~Base();
20*67e74705SXin Li };
21*67e74705SXin Li template <typename T> struct Foo : Base {
FooFoo22*67e74705SXin Li   Foo() {}
23*67e74705SXin Li };
24*67e74705SXin Li extern template class Foo<int>;
f()25*67e74705SXin Li Foo<int> *f() { return new Foo<int>(); }
26