Skip to content

Commit 5545f1b

Browse files
committed
[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
1 parent 70218f6 commit 5545f1b

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-escape %t -- -- -fexceptions
2+
3+
void throwing_throw_nothing() throw() {
4+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions
5+
throw 1;
6+
}
7+
8+
void explicit_int_thrower() throw(int);
9+
10+
void implicit_int_thrower() {
11+
throw 5;
12+
}
13+
14+
void indirect_implicit() throw() {
15+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_implicit' which should not throw exceptions
16+
implicit_int_thrower();
17+
}
18+
19+
void indirect_explicit() throw() {
20+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_explicit' which should not throw exceptions
21+
explicit_int_thrower();
22+
}
23+
24+
struct super_throws {
25+
super_throws() throw(int) { throw 42; }
26+
};
27+
28+
struct sub_throws : super_throws {
29+
sub_throws() throw() : super_throws() {}
30+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions
31+
};

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ void throwing_noexcept() noexcept {
3232
throw 1;
3333
}
3434

35-
void throwing_throw_nothing() throw() {
36-
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions
37-
throw 1;
38-
}
39-
4035
void throw_and_catch() noexcept {
4136
// CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_catch' which should not throw exceptions
4237
try {
@@ -557,7 +552,9 @@ void implicit_int_thrower() {
557552
throw 1;
558553
}
559554

560-
void explicit_int_thrower() throw(int);
555+
void explicit_int_thrower() noexcept(false) {
556+
throw 1;
557+
}
561558

562559
void indirect_implicit() noexcept {
563560
// 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 {
676673
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions
677674
};
678675

679-
struct super_throws_again {
680-
super_throws_again() throw(int);
681-
};
682-
683-
struct sub_throws_again : super_throws_again {
684-
sub_throws_again() noexcept : super_throws_again() {}
685-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws_again' which should not throw exceptions
686-
};
687-
688676
struct init_member_throws {
689677
super_throws s;
690678

0 commit comments

Comments
 (0)