]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGenCXX/mangle-ms-templates.cpp
Vendor import of clang trunk r161861:
[FreeBSD/FreeBSD.git] / test / CodeGenCXX / mangle-ms-templates.cpp
1 // RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
2
3 template<typename T>
4 class Class {
5  public:
6   void method() {}
7 };
8
9 class Typename { };
10
11 template<typename T>
12 class Nested { };
13
14 template<bool flag>
15 class BoolTemplate {
16  public:
17   BoolTemplate() {}
18 };
19
20 template<int param>
21 class IntTemplate {
22  public:
23   IntTemplate() {}
24 };
25
26 template<>
27 class BoolTemplate<true> {
28  public:
29   BoolTemplate() {}
30   template<class T> void Foo(T arg) {}
31 };
32
33 void template_mangling() {
34   Class<Typename> c1;
35   c1.method();
36 // CHECK: call {{.*}} @"\01?method@?$Class@VTypename@@@@QAEXXZ"
37
38   Class<Nested<Typename> > c2;
39   c2.method();
40 // CHECK: call {{.*}} @"\01?method@?$Class@V?$Nested@VTypename@@@@@@QAEXXZ"
41
42   BoolTemplate<false> _false;
43 // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ"
44
45   BoolTemplate<true> _true;
46   // PR13158
47   _true.Foo(1);
48 // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ"
49 // CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z"
50
51   IntTemplate<5> five;
52 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ"
53
54   IntTemplate<11> eleven;
55 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ"
56
57   IntTemplate<65535> ffff;
58 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ"
59 }
60
61 namespace space {
62   template<class T> const T& foo(const T& l) { return l; }
63 }
64 // CHECK: "\01??$foo@H@space@@YAABHABH@Z"
65
66 void use() {
67   space::foo(42);
68 }