1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
4 typedef unsigned int NSUInteger;
5 typedef long NSInteger;
6 typedef signed char BOOL;
8 #define nil ((void*) 0)
16 @interface NSError : NSObject
19 @interface NSString : NSObject
22 @interface NSString (NSStringExtensionMethods)
23 - (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))block;
26 @interface NSData : NSObject
29 @interface NSData (ASBase64)
30 - (NSString *)encodedString:(NSInteger)position;
31 - (NSData *)compressedData;
34 typedef void (^TDataCompletionBlock)(NSData *data, NSError *error);
35 @interface TMap : NSObject
36 - (NSString *)identifier;
38 + (TMap *)mapForID:(NSString *)identifier;
39 - (void)dataWithCompletionBlock:(TDataCompletionBlock)block;
42 typedef enum : NSUInteger {
47 @interface TConnection : NSObject
48 - (void)sendString:(NSString *)string;
49 - (void)sendFormat:(NSString *)format, ...;
50 - (void)sendResponseCode:(TResponseCode)responseCode dataFollows:(BOOL)flag
51 format:(NSString *)format, ...;
54 @interface TServer : NSObject
57 @implementation TServer
58 - (void)serverConnection:(TConnection *)connection getCommand:(NSString *)str
60 NSString *mapID = nil;
61 TMap *map = [TMap mapForID:mapID];
62 // Make sure we do not map code generated for the block to the above line.
63 // CHECK: define internal void @"__39-[TServer serverConnection:getCommand:]_block_invoke"
64 // CHECK: call void @llvm.objc.storeStrong(ptr [[CONNECTION_ADDR:%.*]], ptr [[ONE:%.*]]) [[NUW:#[0-9]+]]
65 // CHECK: call void @llvm.objc.storeStrong(ptr [[STR_ADDR:%.*]], ptr [[THREE:%.*]]) [[NUW]]
66 // CHECK: call {{.*}}@objc_msgSend{{.*}}, !dbg ![[LINE_ABOVE:[0-9]+]]
67 // CHECK: getelementptr
68 // CHECK-NOT: !dbg, ![[LINE_ABOVE]]
69 // CHECK: call void @llvm.objc.storeStrong(ptr [[STR_ADDR]], ptr null) [[NUW]]
70 // CHECK-NEXT: call void @llvm.objc.storeStrong(ptr [[CONNECTION_ADDR]], ptr null) [[NUW]]
72 // CHECK: attributes [[NUW]] = { nounwind }
73 [map dataWithCompletionBlock:^(NSData *data, NSError *error) {
75 NSString *encoded = [[data compressedData] encodedString:18];
76 [connection sendResponseCode:TOK dataFollows:YES
77 format:@"Sending \"%@\" (%@)", [map name], [map identifier]];
78 [encoded enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
79 [connection sendFormat:@"%@\r\n", line];
81 [connection sendString:@".\r\n"];
83 [connection sendResponseCode:TError dataFollows:NO
84 format:@"Failed \"%@\" (%@)", [map name], [map identifier]];