eleviant 1383dd8dbe
[lldb][test] Fix TestLongjmp on Linux (#185464)
Patch fixes llvm.org/pr20231.
The original test was expecting clock() to return 0 when stepping in
debugger which in reality can never happen.
2026-03-10 16:22:27 +01:00

22 lines
379 B
C

#include <setjmp.h>
#include <stdio.h>
#include <time.h>
jmp_buf j;
void do_jump(void) {
// We can't let the compiler know this will always happen or it might make
// optimizations that break our test.
if (clock())
longjmp(j, 1); // non-local goto
}
int main(void) {
if (setjmp(j) == 0)
do_jump();
else
return 0; // destination of longjmp
return 1;
}