xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/debug-info-nested-blocks.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -emit-llvm -gdwarf-2 -fblocks -o - -x objective-c %s| FileCheck %s
2*0a6a1f1dSLionel Sambuc// This code triggered a bug where a dbg.declare intrinsic ended up with the
3*0a6a1f1dSLionel Sambuc// wrong parent and subsequently failed the Verifier.
4*0a6a1f1dSLionel Sambucvoid baz(id b);
5*0a6a1f1dSLionel Sambucvoid fub(id block);
6*0a6a1f1dSLionel Sambucint foo(void);
7*0a6a1f1dSLionel Sambucvoid bar(void) {
8*0a6a1f1dSLionel Sambuc  fub(^() {
9*0a6a1f1dSLionel Sambuc      id a;
10*0a6a1f1dSLionel Sambuc      id b = [a bar:^(int e){}];
11*0a6a1f1dSLionel Sambuc      if (b) {
12*0a6a1f1dSLionel Sambuc        ^() {
13*0a6a1f1dSLionel Sambuc            if ((0 && foo()) ? 1 : 0) {
14*0a6a1f1dSLionel Sambuc              baz([a aMessage]);
15*0a6a1f1dSLionel Sambuc            }
16*0a6a1f1dSLionel Sambuc        };
17*0a6a1f1dSLionel Sambuc      }
18*0a6a1f1dSLionel Sambuc  });
19*0a6a1f1dSLionel Sambuc}
20*0a6a1f1dSLionel Sambuc
21*0a6a1f1dSLionel Sambuc// Verify that debug info for BlockPointerDbgLoc is emitted for the
22*0a6a1f1dSLionel Sambuc// innermost block.
23*0a6a1f1dSLionel Sambuc//
24*0a6a1f1dSLionel Sambuc// CHECK: define {{.*}}void @__bar_block_invoke_3(i8* %.block_descriptor)
25*0a6a1f1dSLionel Sambuc// CHECK: %[[BLOCKADDR:.*]] = alloca <{{.*}}>*, align
26*0a6a1f1dSLionel Sambuc// CHECK: call void @llvm.dbg.declare(metadata {{.*}}%[[BLOCKADDR]]
27