brintos

brintos / llvm-project-archived public Read only

0
0
Text · 865 B · cb5ac8d Raw
27 lines · cpp
1// RUN: %check_clang_tidy %s modernize-avoid-setjmp-longjmp %t2 3typedef void *jmp_buf;4extern int __setjmpimpl(jmp_buf);5#define setjmp(x) __setjmpimpl(x)6[[noreturn]] extern void longjmp(jmp_buf, int);7 8namespace std {9using ::jmp_buf;10using ::longjmp;11}12 13static jmp_buf env;14void g() {15  std::longjmp(env, 1);16  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead [modernize-avoid-setjmp-longjmp]17  ::longjmp(env, 1);18  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead19  longjmp(env, 1);20  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead21}22 23void f() {24  (void)setjmp(env);25  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not call 'setjmp'; consider using exception handling instead26}27