xref: /llvm-project/clang/test/CodeGenCXX/dllimport-unique-external.cpp (revision 477f9cea77e6d55ecddaafbedccd418750c40dbd)
1*477f9ceaSWolfgang Pieb // 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*477f9ceaSWolfgang Pieb // 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*477f9ceaSWolfgang Pieb // 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*477f9ceaSWolfgang Pieb 
5*477f9ceaSWolfgang Pieb template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func(); };
6*477f9ceaSWolfgang Pieb 
7*477f9ceaSWolfgang Pieb // Make sure that we do not import classes with unique external linkage.
8*477f9ceaSWolfgang Pieb // Note that MSVC does indeed expect the called function to be defined elsewhere.
func1()9*477f9ceaSWolfgang Pieb void func1() {
10*477f9ceaSWolfgang Pieb   class LocalCRTP : public ImportedClassTemplate<LocalCRTP> {};
11*477f9ceaSWolfgang Pieb   LocalCRTP lc;
12*477f9ceaSWolfgang Pieb   lc.func();
13*477f9ceaSWolfgang Pieb }
14*477f9ceaSWolfgang Pieb 
15*477f9ceaSWolfgang Pieb namespace {
16*477f9ceaSWolfgang Pieb   class AnonNSCRTP : public ImportedClassTemplate<AnonNSCRTP> {};
17*477f9ceaSWolfgang Pieb   AnonNSCRTP ac;
18*477f9ceaSWolfgang Pieb }
19*477f9ceaSWolfgang Pieb 
func2()20*477f9ceaSWolfgang Pieb void func2() {
21*477f9ceaSWolfgang Pieb   ac.func();
22*477f9ceaSWolfgang Pieb }
23*477f9ceaSWolfgang Pieb 
24*477f9ceaSWolfgang Pieb // MSC-NOT: declare {{.*}}dllimport
25*477f9ceaSWolfgang Pieb // MSC:     call {{.*}}@"?func@?$ImportedClassTemplate@VLocalCRTP@?1??func1{{.*}}"
26*477f9ceaSWolfgang Pieb // MSC-NOT: declare {{.*}}dllimport
27*477f9ceaSWolfgang Pieb // MSC:     call {{.*}}@"?func@?$ImportedClassTemplate@VAnonNSCRTP@?{{.*}}"
28*477f9ceaSWolfgang Pieb // MSC-NOT: declare {{.*}}dllimport
29*477f9ceaSWolfgang Pieb 
30*477f9ceaSWolfgang Pieb // PS-NOT:  declare {{.*}}dllimport
31*477f9ceaSWolfgang Pieb // PS:      call {{.*}}@_ZN21ImportedClassTemplateIZ5func1vE9LocalCRTPE4funcEv
32*477f9ceaSWolfgang Pieb // PS-NOT:  declare {{.*}}dllimport
33*477f9ceaSWolfgang Pieb // PS:      call {{.*}}@_ZN21ImportedClassTemplateIN12_GLOBAL__N_110AnonNSCRTPEE4funcEv
34*477f9ceaSWolfgang Pieb // PS-NOT:  declare {{.*}}dllimport
35