1// RUN: %check_clang_tidy %s cert-err52-cpp %t
2
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 [cert-err52-cpp]
17 ::longjmp(env, 1);
18 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
19 longjmp(env, 1);
20 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
21}
22
23void f() {
24 (void)setjmp(env);
25 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not call 'setjmp'; consider using exception handling instead
26}
27

source code of clang-tools-extra/test/clang-tidy/checkers/cert/setlongjmp.cpp