blob: c913a972e14fe6d41b0d3bcb305457917d104ef1 [file] [log] [blame]
Manman Ren3c7a0e12013-01-04 18:51:35 +00001// REQUIRES: x86-64-registered-target
2// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-default-synthesize-properties -fobjc-arc -O0 -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
3
4// rdar://11562117
5typedef unsigned int NSUInteger;
6typedef long NSInteger;
7typedef signed char BOOL;
8
9#define nil ((void*) 0)
10#define YES ((BOOL)1)
11#define NO ((BOOL)0)
12
13@interface NSObject
14- (id)init;
15@end
16
17@interface NSError : NSObject
18@end
19
20@interface NSString : NSObject
21@end
22
23@interface NSString (NSStringExtensionMethods)
24- (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))block;
25@end
26
27@interface NSData : NSObject
28@end
29
30@interface NSData (ASBase64)
31- (NSString *)encodedString:(NSInteger)position;
32- (NSData *)compressedData;
33@end
34
35typedef void (^TDataCompletionBlock)(NSData *data, NSError *error);
36@interface TMap : NSObject
37- (NSString *)identifier;
38- (NSString *)name;
39+ (TMap *)mapForID:(NSString *)identifier;
40- (void)dataWithCompletionBlock:(TDataCompletionBlock)block;
41@end
42
43typedef enum : NSUInteger {
44 TOK = 100,
45 TError = 125,
46} TResponseCode;
47
48@interface TConnection : NSObject
49- (void)sendString:(NSString *)string;
50- (void)sendFormat:(NSString *)format, ...;
51- (void)sendResponseCode:(TResponseCode)responseCode dataFollows:(BOOL)flag
52 format:(NSString *)format, ...;
53@end
54
55@interface TServer : NSObject
56@end
57
58@implementation TServer
59- (void)serverConnection:(TConnection *)connection getCommand:(NSString *)str
60{
61 NSString *mapID = nil;
62 TMap *map = [TMap mapForID:mapID];
63// Make sure we do not map code generated for the block to the above line.
64// CHECK: define internal void @"__39-[TServer serverConnection:getCommand:]_block_invoke"
Bill Wendling4e1125f2013-02-22 09:10:20 +000065// CHECK: call void @objc_storeStrong(i8** [[ZERO:%.*]], i8* [[ONE:%.*]]) [[NUW:#[0-9]+]]
66// CHECK: call void @objc_storeStrong(i8** [[TWO:%.*]], i8* [[THREE:%.*]]) [[NUW]]
Manman Rendf0be6d2013-01-05 00:01:42 +000067// CHECK: bitcast %5** [[TMP:%.*]] to i8**
Bill Wendling4e1125f2013-02-22 09:10:20 +000068// CHECK: call void @objc_storeStrong(i8** [[VAL1:%.*]], i8* null) [[NUW]], !dbg ![[MD1:.*]]
Manman Rendf0be6d2013-01-05 00:01:42 +000069// CHECK: bitcast %4** [[TMP:%.*]] to i8**
Bill Wendling4e1125f2013-02-22 09:10:20 +000070// CHECK: call void @objc_storeStrong(i8** [[VAL2:%.*]], i8* null) [[NUW]], !dbg ![[MD1]]
Manman Ren3c7a0e12013-01-04 18:51:35 +000071// CHECK-NEXT: ret
Bill Wendling4e1125f2013-02-22 09:10:20 +000072// CHECK: attributes [[NUW]] = { nounwind }
73// CHECK: ![[MD1]] = metadata !{i32 87
Manman Ren3c7a0e12013-01-04 18:51:35 +000074 [map dataWithCompletionBlock:^(NSData *data, NSError *error) {
75 if (data) {
76 NSString *encoded = [[data compressedData] encodedString:18];
77 [connection sendResponseCode:TOK dataFollows:YES
78 format:@"Sending \"%@\" (%@)", [map name], [map identifier]];
79 [encoded enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
80 [connection sendFormat:@"%@\r\n", line];
81 }];
82 [connection sendString:@".\r\n"];
83 } else {
84 [connection sendResponseCode:TError dataFollows:NO
85 format:@"Failed \"%@\" (%@)", [map name], [map identifier]];
86 }
87 }];
88}
89@end