You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/readability/avoid-return-with-void-value.cpp
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,18 @@ void f2() {
12
12
returnf1();
13
13
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
14
14
// CHECK-MESSAGES-LENIENT: :[[@LINE-2]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
15
+
// CHECK-FIXES: f1(); return;
15
16
}
16
17
17
18
voidf3(bool b) {
18
19
if (b) returnf1();
19
20
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
21
+
// CHECK-FIXES: if (b) {f1(); return;}
20
22
returnf2();
21
23
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
22
24
// CHECK-MESSAGES-LENIENT: :[[@LINE-2]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
25
+
// CHECK-FIXES: f2(); return;
26
+
// CHECK-FIXES-LENIENT: f2(); return;
23
27
}
24
28
25
29
template<classT>
@@ -29,6 +33,8 @@ void f5() {
29
33
return f4<void>();
30
34
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
31
35
// CHECK-MESSAGES-LENIENT: :[[@LINE-2]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
36
+
// CHECK-FIXES: f4<void>(); return;
37
+
// CHECK-FIXES-LENIENT: f4<void>(); return;
32
38
}
33
39
34
40
voidf6() { return; }
@@ -41,6 +47,8 @@ void f9() {
41
47
return (void)f7();
42
48
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
43
49
// CHECK-MESSAGES-LENIENT: :[[@LINE-2]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
50
+
// CHECK-FIXES: (void)f7(); return;
51
+
// CHECK-FIXES-LENIENT: (void)f7(); return;
44
52
}
45
53
46
54
#defineRETURN_VOIDreturn (void)1
@@ -50,12 +58,12 @@ void f10() {
50
58
// CHECK-MESSAGES-INCLUDE-MACROS: :[[@LINE-1]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
51
59
}
52
60
53
-
template <typename A>
61
+
template <typename A>
54
62
structC {
55
63
C(A) {}
56
64
};
57
65
58
-
template <classT>
66
+
template <classT>
59
67
C<T> f11() { return {}; }
60
68
61
69
using VOID = void;
@@ -66,4 +74,6 @@ VOID f13() {
66
74
returnf12();
67
75
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
68
76
// CHECK-MESSAGES-LENIENT: :[[@LINE-2]]:5: warning: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
0 commit comments