1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -fblocks -fobjc-arc -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
5 typedef unsigned int NSUInteger;
6 typedef long NSInteger;
7 typedef signed char BOOL;
9 #define nil ((void*) 0)
17 @interface NSError : NSObject
20 @interface NSString : NSObject
23 @interface NSString (NSStringExtensionMethods)
24 - (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))block;
27 @interface NSData : NSObject
30 @interface NSData (ASBase64)
31 - (NSString *)encodedString:(NSInteger)position;
32 - (NSData *)compressedData;
35 typedef void (^TDataCompletionBlock)(NSData *data, NSError *error);
36 @interface TMap : NSObject
37 - (NSString *)identifier;
39 + (TMap *)mapForID:(NSString *)identifier;
40 - (void)dataWithCompletionBlock:(TDataCompletionBlock)block;
43 typedef enum : NSUInteger {
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, ...;
55 @interface TServer : NSObject
58 @implementation TServer
59 - (void)serverConnection:(TConnection *)connection getCommand:(NSString *)str
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"
65 // CHECK: call void @llvm.objc.storeStrong(i8** [[ZERO:%.*]], i8* [[ONE:%.*]]) [[NUW:#[0-9]+]]
66 // CHECK: call void @llvm.objc.storeStrong(i8** [[TWO:%.*]], i8* [[THREE:%.*]]) [[NUW]]
67 // CHECK: call {{.*}}@objc_msgSend{{.*}}, !dbg ![[LINE_ABOVE:[0-9]+]]
68 // CHECK: getelementptr
69 // CHECK-NOT: !dbg, ![[LINE_ABOVE]]
70 // CHECK: bitcast %5** [[TMP:%.*]] to i8**
71 // CHECK-NOT: !dbg, ![[LINE_ABOVE]]
72 // CHECK: call void @llvm.objc.storeStrong(i8** [[VAL1:%.*]], i8* null) [[NUW]]
73 // CHECK-NEXT: bitcast %4** [[TMP:%.*]] to i8**
74 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** [[VAL2:%.*]], i8* null) [[NUW]]
76 // CHECK: attributes [[NUW]] = { nounwind }
77 [map dataWithCompletionBlock:^(NSData *data, NSError *error) {
79 NSString *encoded = [[data compressedData] encodedString:18];
80 [connection sendResponseCode:TOK dataFollows:YES
81 format:@"Sending \"%@\" (%@)", [map name], [map identifier]];
82 [encoded enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
83 [connection sendFormat:@"%@\r\n", line];
85 [connection sendString:@".\r\n"];
87 [connection sendResponseCode:TError dataFollows:NO
88 format:@"Failed \"%@\" (%@)", [map name], [map identifier]];