Debian Codegraph @

clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-openmp.cpp

raw
1 // RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-fopenmp=libomp -extra-arg=-fexceptions --
2
3 int thrower() {
4 throw 42;
5 }
6
7 void ok_parallel() {
8 #pragma omp parallel
9 thrower();
10 }
11
12 void bad_for_header_XFAIL(const int a) noexcept {
13 #pragma omp for
14 for (int i = 0; i < thrower(); i++)
15 ;
16 // FIXME: this really should be caught by bugprone-exception-escape.
17 // https://bugs.llvm.org/show_bug.cgi?id=41102
18 }
19
20 void ok_forloop(const int a) {
21 #pragma omp for
22 for (int i = 0; i < a; i++)
23 thrower();
24 }
25
26 void some_exception_just_so_that_check_clang_tidy_shuts_up() noexcept {
27 thrower();
28 }
29 // CHECK-MESSAGES: :[[@LINE-3]]:6: warning: an exception may be thrown in function 'some_exception_just_so_that_check_clang_tidy_shuts_up' which should not throw exceptions