xref: /llvm-project/clang/test/CodeGenObjCXX/mangle.mm (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -fblocks -o - | FileCheck %s
2
3// CHECK: @"_ZZ11+[A shared]E1a" = internal global
4// CHECK: @"_ZZ11-[A(Foo) f]E1a" = internal global
5// CHECK: v56@0:8i16i20i24i28i32i36i40i44^i48
6
7@interface A
8@end
9
10@implementation A
11
12+ (A *)shared {
13  static A* a;
14
15  return a;
16}
17
18@end
19
20@interface A(Foo)
21@end
22
23@implementation A(Foo)
24- (int)f {
25  // FIXME: Add a member function to s and make sure that it's mangled correctly.
26  struct s {
27  };
28
29  static s a;
30
31  return 0;
32}
33@end
34
35// PR6468
36@interface Test
37- (void) process: (int)r3 :(int)r4 :(int)r5 :(int)r6 :(int)r7 :(int)r8 :(int)r9 :(int)r10 :(int &)i;
38@end
39
40@implementation Test
41- (void) process: (int)r3 :(int)r4 :(int)r5 :(int)r6 :(int)r7 :(int)r8 :(int)r9 :(int)r10 :(int &)i {
42}
43@end
44
45@interface NX
46- (void)Meth;
47@end
48
49@implementation NX
50- (void)Meth {
51  void uiIsVisible();
52// CHECK: call void @_Z11uiIsVisiblev
53  uiIsVisible();
54}
55@end
56
57// Don't crash when mangling an enum whose semantic context
58// is a class extension (which looks anonymous in the AST).
59// The other tests here are just for coverage.
60@interface Test2 @end
61@interface Test2 ()
62@property (assign) enum { T2x, T2y, T2z } axis;
63@end
64@interface Test2 (a)
65@property (assign) enum { T2i, T2j, T2k } dimension;
66@end
67@implementation Test2 {
68@public
69  enum { T2a, T2b, T2c } alt_axis;
70}
71@end
72template <class T> struct Test2Template { Test2Template() {} }; // must have a member that we'll instantiate and mangle
73void test2(Test2 *t) {
74  Test2Template<decltype(t.axis)> t0;
75  Test2Template<decltype(t.dimension)> t1;
76  Test2Template<decltype(t->alt_axis)> t2;
77}
78
79@protocol P;
80void overload1(A<P>*) {}
81// CHECK-LABEL: define{{.*}} void @_Z9overload1PU11objcproto1P1A
82void overload1(const A<P>*) {}
83// CHECK-LABEL: define{{.*}} void @_Z9overload1PKU11objcproto1P1A
84void overload1(A<P>**) {}
85// CHECK-LABEL: define{{.*}} void @_Z9overload1PPU11objcproto1P1A
86void overload1(A<P>*const*) {}
87// CHECK-LABEL: define{{.*}} void @_Z9overload1PKPU11objcproto1P1A
88void overload1(A<P>***) {}
89// CHECK-LABEL: define{{.*}} void @_Z9overload1PPPU11objcproto1P1A
90void overload1(void (f)(A<P>*)) {}
91// CHECK-LABEL: define{{.*}} void @_Z9overload1PFvPU11objcproto1P1AE
92
93template<typename T> struct X { void f(); };
94template<> void X<A*>::f() {}
95// CHECK-LABEL: define{{.*}} void @_ZN1XIP1AE1fEv
96template<> void X<A<P>*>::f() {}
97// CHECK-LABEL: define{{.*}} void @_ZN1XIPU11objcproto1P1AE1fEv
98
99// CHECK-LABEL: define{{.*}} void @_Z12kindof_test2PU8__kindof5Test2
100void kindof_test2(__kindof Test2 *t2) { }
101
102@interface Parameterized<T, U> : A
103@end
104
105// CHECK-LABEL: define{{.*}} void @_Z19parameterized_test1P13ParameterizedIP1AP4TestE
106void parameterized_test1(Parameterized<A *, Test *> *p) {}
107
108// CHECK-LABEL: define{{.*}} void @_Z19parameterized_test2PU8__kindof13ParameterizedIP1AP4TestE
109void parameterized_test2(__kindof Parameterized<A *, Test *> *p) {}
110
111// CHECK-LABEL: define{{.*}} void @_Z19parameterized_test3P13Parameterized
112void parameterized_test3(Parameterized *p) {}
113
114// CHECK-LABEL: define {{.*}}void @_Z1fP11objc_object
115void f(__attribute__((ns_consumed)) id) {}
116// CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectS0_S0_E
117void f(id (*fn)(__attribute__((ns_consumed)) id, id)) {}
118// CHECK-LABEL: define {{.*}}void @_Z1fU13block_pointerFvP11objc_objectE
119void f(void (^)(__attribute__((ns_consumed)) id)) {}
120