xref: /llvm-project/clang/test/CodeGenCXX/dllexport-unique-external.cpp (revision 477f9cea77e6d55ecddaafbedccd418750c40dbd)
1 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -disable-llvm-passes -o - %s | FileCheck --check-prefix=MSC %s
2 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-scei-ps4 -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s | FileCheck --check-prefix=PS %s
3 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-sie-ps5 -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s | FileCheck --check-prefix=PS %s
4 
5 template <typename T> struct __declspec(dllexport) ExportedClassTemplate { void func(); };
6 
7 // Make sure that we do not export classes with unique external linkage.
8 // Note that MSVC does indeed export the symbols in the MSC check string.
func1()9 void func1() {
10   class LocalCRTP : public ExportedClassTemplate<LocalCRTP> {};
11   LocalCRTP lc;
12   lc.func();
13 }
14 
15 namespace {
16   class AnonNSCRTP : public ExportedClassTemplate<AnonNSCRTP> {};
17   AnonNSCRTP ac;
18 }
19 
func2()20 void func2() {
21   ac.func();
22 }
23 
24 // MSC-NOT: declare {{.*}}dllexport
25 // MSC:     call {{.*}}@"?func@?$ExportedClassTemplate@VLocalCRTP@?1??func1@@{{.*}}"
26 // MSC-NOT: declare {{.*}}dllexport
27 // MSC:     call {{.*}}@"?func@?$ExportedClassTemplate@VAnonNSCRTP@?{{.*}}"
28 // MSC-NOT: declare {{.*}}dllexport
29 
30 // PS-NOT:  declare {{.*}}dllexport
31 // PS:      call {{.*}}@_ZN21ExportedClassTemplateIZ5func1vE9LocalCRTPE4funcEv
32 // PS-NOT:  declare {{.*}}dllexport
33 // PS:      call {{.*}}@_ZN21ExportedClassTemplateIN12_GLOBAL__N_110AnonNSCRTPEE4funcEv
34 // PS-NOT:  declare {{.*}}dllexport
35