xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/modern-write-bf-abi.mm (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
3*f4a2713aSLionel Sambuc// rdar://13138459
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc// -Did="void*" -DSEL="void *" -DClass="void*"
6*f4a2713aSLionel Sambuc@interface NSMutableArray {
7*f4a2713aSLionel Sambuc  id isa;
8*f4a2713aSLionel Sambuc}
9*f4a2713aSLionel Sambuc@end
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuctypedef unsigned char BOOL;
12*f4a2713aSLionel Sambuctypedef unsigned long NSUInteger;
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc__attribute__((visibility("hidden")))
15*f4a2713aSLionel Sambuc@interface __NSArrayM : NSMutableArray {
16*f4a2713aSLionel Sambuc    NSUInteger _used;
17*f4a2713aSLionel Sambuc    NSUInteger _doHardRetain:1;
18*f4a2713aSLionel Sambuc    NSUInteger _doWeakAccess:1;
19*f4a2713aSLionel Sambuc#if __LP64__
20*f4a2713aSLionel Sambuc    NSUInteger _size:62;
21*f4a2713aSLionel Sambuc#else
22*f4a2713aSLionel Sambuc    NSUInteger _size:30;
23*f4a2713aSLionel Sambuc#endif
24*f4a2713aSLionel Sambuc    NSUInteger _hasObjects:1;
25*f4a2713aSLionel Sambuc    NSUInteger _hasStrongReferences:1;
26*f4a2713aSLionel Sambuc#if __LP64__
27*f4a2713aSLionel Sambuc    NSUInteger _offset:62;
28*f4a2713aSLionel Sambuc#else
29*f4a2713aSLionel Sambuc    NSUInteger _offset:30;
30*f4a2713aSLionel Sambuc#endif
31*f4a2713aSLionel Sambuc    unsigned long _mutations;
32*f4a2713aSLionel Sambuc    id *_list;
33*f4a2713aSLionel Sambuc}
34*f4a2713aSLionel Sambuc@end
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc
37*f4a2713aSLionel Sambucid __CFAllocateObject2();
38*f4a2713aSLionel SambucBOOL objc_collectingEnabled();
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc@implementation __NSArrayM
41*f4a2713aSLionel Sambuc+ (id)__new:(const id [])objects :(NSUInteger)count :(BOOL)hasObjects :(BOOL)hasStrong :(BOOL)transferRetain {
42*f4a2713aSLionel Sambuc    __NSArrayM *newArray = (__NSArrayM *)__CFAllocateObject2();
43*f4a2713aSLionel Sambuc    newArray->_size = count;
44*f4a2713aSLionel Sambuc    newArray->_mutations = 1;
45*f4a2713aSLionel Sambuc    newArray->_doHardRetain = (hasObjects && hasStrong);
46*f4a2713aSLionel Sambuc    newArray->_doWeakAccess = (objc_collectingEnabled() && !hasStrong);
47*f4a2713aSLionel Sambuc    newArray->_hasObjects = hasObjects;
48*f4a2713aSLionel Sambuc    newArray->_hasStrongReferences = hasStrong;
49*f4a2713aSLionel Sambuc    newArray->_list = 0;
50*f4a2713aSLionel Sambuc    return *newArray->_list;
51*f4a2713aSLionel Sambuc}
52*f4a2713aSLionel Sambuc@end
53*f4a2713aSLionel Sambuc
54*f4a2713aSLionel Sambuc// Test2
55*f4a2713aSLionel Sambuc@interface Super {
56*f4a2713aSLionel Sambuc  int ivar_super_a : 5;
57*f4a2713aSLionel Sambuc}
58*f4a2713aSLionel Sambuc@end
59*f4a2713aSLionel Sambuc
60*f4a2713aSLionel Sambuc@interface A : Super {
61*f4a2713aSLionel Sambuc@public
62*f4a2713aSLionel Sambuc  int ivar_a : 5;
63*f4a2713aSLionel Sambuc}
64*f4a2713aSLionel Sambuc@end
65*f4a2713aSLionel Sambuc
66*f4a2713aSLionel Sambucint f0(A *a) {
67*f4a2713aSLionel Sambuc  return a->ivar_a;
68*f4a2713aSLionel Sambuc}
69*f4a2713aSLionel Sambuc
70*f4a2713aSLionel Sambuc@interface A () {
71*f4a2713aSLionel Sambuc@public
72*f4a2713aSLionel Sambuc  int ivar_ext_a : 5;
73*f4a2713aSLionel Sambuc  int ivar_ext_b : 5;
74*f4a2713aSLionel Sambuc}@end
75*f4a2713aSLionel Sambuc
76*f4a2713aSLionel Sambucint f1(A *a) {
77*f4a2713aSLionel Sambuc  return a->ivar_ext_a + a->ivar_a;
78*f4a2713aSLionel Sambuc}
79*f4a2713aSLionel Sambuc
80*f4a2713aSLionel Sambuc@interface A () {
81*f4a2713aSLionel Sambuc@public
82*f4a2713aSLionel Sambuc  int ivar_ext2_a : 5;
83*f4a2713aSLionel Sambuc  int ivar_ext2_b : 5;
84*f4a2713aSLionel Sambuc}@end
85*f4a2713aSLionel Sambuc
86*f4a2713aSLionel Sambucint f2(A* a) {
87*f4a2713aSLionel Sambuc  return a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a;
88*f4a2713aSLionel Sambuc}
89*f4a2713aSLionel Sambuc
90*f4a2713aSLionel Sambuc@implementation A {
91*f4a2713aSLionel Sambuc@public
92*f4a2713aSLionel Sambuc  int ivar_b : 5;
93*f4a2713aSLionel Sambuc  int ivar_c : 5;
94*f4a2713aSLionel Sambuc  int ivar_d : 5;
95*f4a2713aSLionel Sambuc}
96*f4a2713aSLionel Sambuc@end
97*f4a2713aSLionel Sambuc
98*f4a2713aSLionel Sambucint f3(A *a) {
99*f4a2713aSLionel Sambuc  return a->ivar_d + a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a;
100*f4a2713aSLionel Sambuc}
101*f4a2713aSLionel Sambuc
102*f4a2713aSLionel Sambuc__attribute__((objc_root_class)) @interface Base
103*f4a2713aSLionel Sambuc{
104*f4a2713aSLionel Sambuc    struct objc_class *isa;
105*f4a2713aSLionel Sambuc    int full;
106*f4a2713aSLionel Sambuc    int full2: 32;
107*f4a2713aSLionel Sambuc    int _refs: 8;
108*f4a2713aSLionel Sambuc    int field2: 3;
109*f4a2713aSLionel Sambuc    unsigned f3: 8;
110*f4a2713aSLionel Sambuc    short cc;
111*f4a2713aSLionel Sambuc    unsigned g: 16;
112*f4a2713aSLionel Sambuc    int r2: 8;
113*f4a2713aSLionel Sambuc    int r3: 8;
114*f4a2713aSLionel Sambuc    int r4: 2;
115*f4a2713aSLionel Sambuc    int r5: 8;
116*f4a2713aSLionel Sambuc    char c;
117*f4a2713aSLionel Sambuc}
118*f4a2713aSLionel Sambuc@end
119*f4a2713aSLionel Sambuc
120*f4a2713aSLionel Sambuc@implementation Base @end
121