diff options
author | Piotr Zegar <me@piotrzegar.pl> | 2023-05-07 17:19:33 +0000 |
---|---|---|
committer | Piotr Zegar <me@piotrzegar.pl> | 2023-05-07 17:56:47 +0000 |
commit | 5545f1bbd4e18b9ffda993ee13460d417194941a (patch) | |
tree | f836795b69ce0472f18e7fcba3d7f27d0f9e2f2e /clang-tools-extra/test | |
parent | 70218f6f83fe8aab28277e0b4507724b5e999ee4 (diff) | |
download | llvm-5545f1bbd4e18b9ffda993ee13460d417194941a.tar.gz |
[clang-tidy][NFC] Split bugprone-exception-escape tests
Split tests files into noexcept and throw().
This is preparation for a C++20 support in this check.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D148458
Diffstat (limited to 'clang-tools-extra/test')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp | 31 | ||||
-rw-r--r-- | clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp | 18 |
2 files changed, 34 insertions, 15 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp new file mode 100644 index 000000000000..4a0113b8be3b --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp @@ -0,0 +1,31 @@ +// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-escape %t -- -- -fexceptions + +void throwing_throw_nothing() throw() { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions + throw 1; +} + +void explicit_int_thrower() throw(int); + +void implicit_int_thrower() { + throw 5; +} + +void indirect_implicit() throw() { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_implicit' which should not throw exceptions + implicit_int_thrower(); +} + +void indirect_explicit() throw() { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_explicit' which should not throw exceptions + explicit_int_thrower(); +} + +struct super_throws { + super_throws() throw(int) { throw 42; } +}; + +struct sub_throws : super_throws { + sub_throws() throw() : super_throws() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions +}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp index 78d434854b09..f575a185897c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp @@ -32,11 +32,6 @@ void throwing_noexcept() noexcept { throw 1; } -void throwing_throw_nothing() throw() { - // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions - throw 1; -} - void throw_and_catch() noexcept { // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_catch' which should not throw exceptions try { @@ -557,7 +552,9 @@ void implicit_int_thrower() { throw 1; } -void explicit_int_thrower() throw(int); +void explicit_int_thrower() noexcept(false) { + throw 1; +} void indirect_implicit() noexcept { // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_implicit' which should not throw exceptions @@ -676,15 +673,6 @@ struct sub_throws : super_throws { // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions }; -struct super_throws_again { - super_throws_again() throw(int); -}; - -struct sub_throws_again : super_throws_again { - sub_throws_again() noexcept : super_throws_again() {} - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws_again' which should not throw exceptions -}; - struct init_member_throws { super_throws s; |