aboutsummaryrefslogtreecommitdiff
path: root/test/Rewriter/modern-write-bf-abi.mm
blob: 9f44564008f07773ed23326ae7c23c36240bcfb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
// 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
// rdar://13138459

// -Did="void*" -DSEL="void *" -DClass="void*"
@interface NSMutableArray {
  id isa;
}
@end

typedef unsigned char BOOL;
typedef unsigned long NSUInteger;

__attribute__((visibility("hidden")))
@interface __NSArrayM : NSMutableArray {
    NSUInteger _used;
    NSUInteger _doHardRetain:1;
    NSUInteger _doWeakAccess:1;
#if __LP64__
    NSUInteger _size:62;
#else
    NSUInteger _size:30;
#endif
    NSUInteger _hasObjects:1;
    NSUInteger _hasStrongReferences:1;
#if __LP64__
    NSUInteger _offset:62;
#else
    NSUInteger _offset:30;
#endif
    unsigned long _mutations;
    id *_list;
}
@end


id __CFAllocateObject2();
BOOL objc_collectingEnabled();

@implementation __NSArrayM
+ (id)__new:(const id [])objects :(NSUInteger)count :(BOOL)hasObjects :(BOOL)hasStrong :(BOOL)transferRetain {
    __NSArrayM *newArray = (__NSArrayM *)__CFAllocateObject2();
    newArray->_size = count;
    newArray->_mutations = 1;
    newArray->_doHardRetain = (hasObjects && hasStrong);
    newArray->_doWeakAccess = (objc_collectingEnabled() && !hasStrong);
    newArray->_hasObjects = hasObjects;
    newArray->_hasStrongReferences = hasStrong;
    newArray->_list = 0;
    return *newArray->_list;
}
@end