1// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-dispatch-method=mixed %s -o - | FileCheck %s 2 3// rdar://problem/9279956 4// Test that we generate the proper debug location for a captured self. 5// The second half of this patch is in llvm/tests/DebugInfo/debug-info-blocks.ll 6 7// CHECK: define {{.*}}_block_invoke 8// CHECK: %[[BLOCK:.*]] = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg 9// CHECK-NEXT: store <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %[[BLOCK]], <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA:.*]], align 10// CHECK-NEXT: getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %[[BLOCK]], i32 0, i32 5 11// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{<{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]]}, metadata ![[SELF:[0-9]+]]) 12// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{%1** %d}, metadata ![[D:[0-9]+]]) 13// CHECK: ![[SELF]] = {{.*}} [ DW_TAG_auto_variable ] [self] [line 52] 14// CHECK: ![[D]] = {{.*}} [d] [line 50] 15 16typedef unsigned int NSUInteger; 17 18@protocol NSObject 19@end 20 21@interface NSObject <NSObject> 22- (id)init; 23+ (id)alloc; 24@end 25 26@interface NSDictionary : NSObject 27- (NSUInteger)count; 28@end 29 30@interface NSMutableDictionary : NSDictionary 31@end 32 33@interface A : NSObject { 34@public 35 int ivar; 36} 37@end 38 39static void run(void (^block)(void)) 40{ 41 block(); 42} 43 44@implementation A 45 46- (id)init 47{ 48 if ((self = [super init])) { 49 run(^{ 50 NSMutableDictionary *d = [[NSMutableDictionary alloc] init]; 51 ivar = 42 + (int)[d count]; 52 }); 53 } 54 return self; 55} 56 57@end 58 59int main() 60{ 61 A *a = [[A alloc] init]; 62 return 0; 63} 64