xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/debug-info-block-line.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// REQUIRES: x86-registered-target
2f4a2713aSLionel Sambuc// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc// rdar://11562117
5f4a2713aSLionel Sambuctypedef unsigned int NSUInteger;
6f4a2713aSLionel Sambuctypedef long NSInteger;
7f4a2713aSLionel Sambuctypedef signed char BOOL;
8f4a2713aSLionel Sambuc
9f4a2713aSLionel Sambuc#define nil ((void*) 0)
10f4a2713aSLionel Sambuc#define YES             ((BOOL)1)
11f4a2713aSLionel Sambuc#define NO              ((BOOL)0)
12f4a2713aSLionel Sambuc
13f4a2713aSLionel Sambuc@interface NSObject
14f4a2713aSLionel Sambuc- (id)init;
15f4a2713aSLionel Sambuc@end
16f4a2713aSLionel Sambuc
17f4a2713aSLionel Sambuc@interface NSError : NSObject
18f4a2713aSLionel Sambuc@end
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc@interface NSString : NSObject
21f4a2713aSLionel Sambuc@end
22f4a2713aSLionel Sambuc
23f4a2713aSLionel Sambuc@interface NSString (NSStringExtensionMethods)
24f4a2713aSLionel Sambuc- (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))block;
25f4a2713aSLionel Sambuc@end
26f4a2713aSLionel Sambuc
27f4a2713aSLionel Sambuc@interface NSData : NSObject
28f4a2713aSLionel Sambuc@end
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc@interface NSData (ASBase64)
31f4a2713aSLionel Sambuc- (NSString *)encodedString:(NSInteger)position;
32f4a2713aSLionel Sambuc- (NSData *)compressedData;
33f4a2713aSLionel Sambuc@end
34f4a2713aSLionel Sambuc
35f4a2713aSLionel Sambuctypedef void (^TDataCompletionBlock)(NSData *data, NSError *error);
36f4a2713aSLionel Sambuc@interface TMap : NSObject
37f4a2713aSLionel Sambuc- (NSString *)identifier;
38f4a2713aSLionel Sambuc- (NSString *)name;
39f4a2713aSLionel Sambuc+ (TMap *)mapForID:(NSString *)identifier;
40f4a2713aSLionel Sambuc- (void)dataWithCompletionBlock:(TDataCompletionBlock)block;
41f4a2713aSLionel Sambuc@end
42f4a2713aSLionel Sambuc
43f4a2713aSLionel Sambuctypedef enum : NSUInteger {
44f4a2713aSLionel Sambuc    TOK                = 100,
45f4a2713aSLionel Sambuc    TError = 125,
46f4a2713aSLionel Sambuc} TResponseCode;
47f4a2713aSLionel Sambuc
48f4a2713aSLionel Sambuc@interface TConnection : NSObject
49f4a2713aSLionel Sambuc- (void)sendString:(NSString *)string;
50f4a2713aSLionel Sambuc- (void)sendFormat:(NSString *)format, ...;
51f4a2713aSLionel Sambuc- (void)sendResponseCode:(TResponseCode)responseCode dataFollows:(BOOL)flag
52f4a2713aSLionel Sambuc                         format:(NSString *)format, ...;
53f4a2713aSLionel Sambuc@end
54f4a2713aSLionel Sambuc
55f4a2713aSLionel Sambuc@interface TServer : NSObject
56f4a2713aSLionel Sambuc@end
57f4a2713aSLionel Sambuc
58f4a2713aSLionel Sambuc@implementation TServer
59f4a2713aSLionel Sambuc- (void)serverConnection:(TConnection *)connection getCommand:(NSString *)str
60f4a2713aSLionel Sambuc{
61f4a2713aSLionel Sambuc    NSString    *mapID = nil;
62f4a2713aSLionel Sambuc    TMap       *map = [TMap mapForID:mapID];
63f4a2713aSLionel Sambuc// Make sure we do not map code generated for the block to the above line.
64f4a2713aSLionel Sambuc// CHECK: define internal void @"__39-[TServer serverConnection:getCommand:]_block_invoke"
65f4a2713aSLionel Sambuc// CHECK: call void @objc_storeStrong(i8** [[ZERO:%.*]], i8* [[ONE:%.*]]) [[NUW:#[0-9]+]]
66f4a2713aSLionel Sambuc// CHECK: call void @objc_storeStrong(i8** [[TWO:%.*]], i8* [[THREE:%.*]]) [[NUW]]
67f4a2713aSLionel Sambuc// CHECK: call {{.*}}@objc_msgSend{{.*}}, !dbg ![[LINE_ABOVE:[0-9]+]]
68f4a2713aSLionel Sambuc// CHECK: getelementptr
69f4a2713aSLionel Sambuc// CHECK-NOT: !dbg, ![[LINE_ABOVE]]
70f4a2713aSLionel Sambuc// CHECK: bitcast %5** [[TMP:%.*]] to i8**
71f4a2713aSLionel Sambuc// CHECK-NOT: !dbg, ![[LINE_ABOVE]]
72f4a2713aSLionel Sambuc// CHECK: call void @objc_storeStrong(i8** [[VAL1:%.*]], i8* null) [[NUW]]
73f4a2713aSLionel Sambuc// CHECK-NEXT: bitcast %4** [[TMP:%.*]] to i8**
74f4a2713aSLionel Sambuc// CHECK-NEXT: call void @objc_storeStrong(i8** [[VAL2:%.*]], i8* null) [[NUW]]
75f4a2713aSLionel Sambuc// CHECK-NEXT: ret
76f4a2713aSLionel Sambuc// CHECK: attributes [[NUW]] = { nounwind }
77f4a2713aSLionel Sambuc    [map dataWithCompletionBlock:^(NSData *data, NSError *error) {
78f4a2713aSLionel Sambuc        if (data) {
79f4a2713aSLionel Sambuc            NSString    *encoded = [[data compressedData] encodedString:18];
80f4a2713aSLionel Sambuc            [connection sendResponseCode:TOK dataFollows:YES
81f4a2713aSLionel Sambuc                format:@"Sending \"%@\" (%@)", [map name], [map identifier]];
82f4a2713aSLionel Sambuc            [encoded enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
83f4a2713aSLionel Sambuc                [connection sendFormat:@"%@\r\n", line];
84f4a2713aSLionel Sambuc            }];
85f4a2713aSLionel Sambuc            [connection sendString:@".\r\n"];
86f4a2713aSLionel Sambuc        } else {
87f4a2713aSLionel Sambuc            [connection sendResponseCode:TError dataFollows:NO
88f4a2713aSLionel Sambuc                format:@"Failed \"%@\" (%@)", [map name], [map identifier]];
89f4a2713aSLionel Sambuc        }
90f4a2713aSLionel Sambuc    }];
91f4a2713aSLionel Sambuc}
92f4a2713aSLionel Sambuc@end
93