summaryrefslogtreecommitdiff
path: root/clang/test/Rewriter/rewrite-block-pointer.mm
blob: 58407a7ac5cf68ba69b94c7371d673e8965e838f (about) (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// radar 7638400

typedef void * id;
void *sel_registerName(const char *);

@interface X
@end

void foo(void (^block)(int));

@implementation X
static void enumerateIt(void (^block)(id, id, char *)) {
      foo(^(int idx) { });
}
@end

// radar 7651312
void apply(void (^block)(int));

static void x(int (^cmp)(int, int)) {
	x(cmp);
}

static void y(int (^cmp)(int, int)) {
	apply(^(int sect) {
		x(cmp);
    });
}

// radar 7659483
void *_Block_copy(const void *aBlock);
void x(void (^block)(void)) {
        block = ((__typeof(block))_Block_copy((const void *)(block)));
}

// radar 7682763
@interface Y {
@private
    id _private;
}
- (void (^)(void))f;
@end

typedef void (^void_block_t)(void);

@interface YY {
    void_block_t __completion;
}
@property (copy) void_block_t f;
@end

@implementation Y
- (void (^)(void))f {
    return [_private f];
}

@end

// rdar: //8608902
@protocol CoreDAVAccountInfoProvider;
@protocol CodeProvider;
typedef void (^BDVDiscoveryCompletionHandler)(int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
typedef void (^BDVDiscoveryCompletion)(id<CodeProvider> codeInfo, int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
typedef void (^BDVDiscovery)(int success);
typedef void (^BDVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodeProvider> codeInfo, 
                        int success, id<CoreDAVAccountInfoProvider, CodeProvider> Info);
typedef void (^BLOCK)(id, id<CoreDAVAccountInfoProvider>, id<CodeProvider> codeInfo);
typedef void (^EMPTY_BLOCK)();
typedef void (^  BDVDiscoveryCompletion1  )(id<CodeProvider> codeInfo, int success, id<CoreDAVAccountInfoProvider> discoveredInfo);

void (^BL)(void(^arg1)(), int i1, void(^arg)(int));

typedef void (^iscoveryCompletionHandler)(void(^arg1)(), id<CoreDAVAccountInfoProvider> discoveredInfo);

typedef void (^DVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodeProvider> codeInfo,
			void(^arg1)(), int i1, void(^arg)(id<CoreDAVAccountInfoProvider>),
                        int success, id<CoreDAVAccountInfoProvider, CodeProvider> Info);


@interface I @end
@interface INTF @end
void (^BLINT)(I<CoreDAVAccountInfoProvider>* ARG, INTF<CodeProvider, CoreDAVAccountInfoProvider>* ARG1);

void  test8608902() {
  BDVDiscoveryCompletionHandler ppp;
  ppp(1, 0);
}

void test9204669() {
   __attribute__((__blocks__(byref))) char (^addChangeToData)();

   addChangeToData = ^() {
      return 'b';
   };
   addChangeToData();
}

void test9204669_1() {
   __attribute__((__blocks__(byref))) void (^addChangeToData)();

   addChangeToData = ^() {
    addChangeToData();
   };
}