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