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