llvm-project/clang/test/DebugInfo/CXX/cp-blocks-linetables.cpp
Michael Buch f2aedc21f9
[clang][DebugInfo][test] Move debug-info tests from CodeGenCXX to DebugInfo directory (#154538)
This patch works towards consolidating all Clang debug-info into the
`clang/test/DebugInfo` directory
(https://discourse.llvm.org/t/clang-test-location-of-clang-debug-info-tests/87958).

Here we move only the `clang/test/CodeGenCXX` tests. I created a `CXX`
subdirectory for now because many of the tests I checked actually did
seem C++-specific. There is probably overlap between the `Generic` and
`CXX` subdirectory, but I haven't gone through and audited them all.

The list of files i came up with is:
1. searched for anything with `*debug-info*` in the filename
2. searched for occurrences of `debug-info-kind` in the tests

There's a couple of tests in `clang/test/CodeGenCXX` that still set
`-debug-info-kind`. They probably don't need to do that, but I'm not
changing that as part of this PR.
2025-08-21 09:26:08 +01:00

61 lines
1.2 KiB
C++

// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
// Ensure that we generate a line table entry for the block cleanup.
// CHECK: define {{.*}} @__main_block_invoke
// CHECK: _NSConcreteStackBlock
// CHECK: call {{.*}} @_Block_object_dispose{{.*}}, !dbg ![[L1:[0-9]+]]
// CHECK: ret
void * _NSConcreteStackBlock;
#ifdef __cplusplus
extern "C" void exit(int);
#else
extern void exit(int);
#endif
enum numbers {
zero, one, two, three, four
};
typedef enum numbers (^myblock)(enum numbers);
double test(myblock I) {
return I(three);
}
int main() {
__block enum numbers x = one;
__block enum numbers y = two;
/* Breakpoint for first Block function. */
myblock CL = ^(enum numbers z)
{ enum numbers savex = x;
{ __block enum numbers x = savex;
y = z;
if (y != three)
exit (6);
test (
/* Breakpoint for second Block function. */
^ (enum numbers z) {
if (y != three) {
exit(1);
}
if (x != one)
exit(2);
x = z;
if (x != three)
exit(3);
if (y != three)
exit(4);
return (enum numbers) four;
});}
return x;
};
enum numbers res = (enum numbers)test(CL);
if (res != one)
exit (5);
return 0;
}