|
1 | | -// RUN: %check_clang_tidy %s bugprone-unused-return-value %t -- -- -fexceptions |
| 1 | +// RUN: %check_clang_tidy %s bugprone-unused-return-value %t -- \ |
| 2 | +// RUN: --config="{CheckOptions: {bugprone-unused-return-value.AllowCastToVoid: true}}" -- -fexceptions |
2 | 3 |
|
3 | 4 | namespace std { |
4 | 5 |
|
@@ -81,121 +82,125 @@ std::error_code errorFunc() { |
81 | 82 |
|
82 | 83 | void warning() { |
83 | 84 | std::async(increment, 42); |
84 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used |
85 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
| 85 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 86 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
86 | 87 |
|
87 | 88 | std::async(std::launch::async, increment, 42); |
88 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
89 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 89 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 90 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
90 | 91 |
|
91 | 92 | Foo F; |
92 | 93 | std::launder(&F); |
93 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
94 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 94 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 95 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
95 | 96 |
|
96 | 97 | std::remove(nullptr, nullptr, 1); |
97 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
98 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 98 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 99 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
99 | 100 |
|
100 | 101 | std::remove_if(nullptr, nullptr, nullptr); |
101 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
102 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 102 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 103 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
103 | 104 |
|
104 | 105 | std::unique(nullptr, nullptr); |
105 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
106 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 106 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 107 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
107 | 108 |
|
108 | 109 | std::unique_ptr<Foo> UPtr; |
109 | 110 | UPtr.release(); |
110 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
111 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 111 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 112 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
112 | 113 |
|
113 | 114 | std::string Str; |
114 | 115 | Str.empty(); |
115 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
116 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 116 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 117 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
| 118 | + |
| 119 | + (int)Str.empty(); |
| 120 | + // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 121 | + // CHECK-MESSAGES: [[@LINE-2]]:8: note: cast the expression to void to silence this warning |
117 | 122 |
|
118 | 123 | std::vector<Foo> Vec; |
119 | 124 | Vec.empty(); |
120 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
121 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 125 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 126 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
122 | 127 |
|
123 | 128 | // test discarding return values inside different kinds of statements |
124 | 129 |
|
125 | 130 | auto Lambda = [] { std::remove(nullptr, nullptr, 1); }; |
126 | | - // CHECK-NOTES: [[@LINE-1]]:22: warning: the value {{.*}} should be used |
127 | | - // CHECK-NOTES: [[@LINE-2]]:22: note: cast {{.*}} this warning |
| 131 | + // CHECK-MESSAGES: [[@LINE-1]]:22: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 132 | + // CHECK-MESSAGES: [[@LINE-2]]:22: note: cast the expression to void to silence this warning |
128 | 133 |
|
129 | 134 | if (true) |
130 | 135 | std::remove(nullptr, nullptr, 1); |
131 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
132 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 136 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 137 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
133 | 138 | else if (true) |
134 | 139 | std::remove(nullptr, nullptr, 1); |
135 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
136 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 140 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 141 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
137 | 142 | else |
138 | 143 | std::remove(nullptr, nullptr, 1); |
139 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
140 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 144 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 145 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
141 | 146 |
|
142 | 147 | while (true) |
143 | 148 | std::remove(nullptr, nullptr, 1); |
144 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
145 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 149 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 150 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
146 | 151 |
|
147 | 152 | do |
148 | 153 | std::remove(nullptr, nullptr, 1); |
149 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
150 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 154 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 155 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
151 | 156 | while (true); |
152 | 157 |
|
153 | 158 | for (;;) |
154 | 159 | std::remove(nullptr, nullptr, 1); |
155 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
156 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 160 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 161 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
157 | 162 |
|
158 | 163 | for (std::remove(nullptr, nullptr, 1);;) |
159 | | - // CHECK-NOTES: [[@LINE-1]]:8: warning: the value {{.*}} should be used |
160 | | - // CHECK-NOTES: [[@LINE-2]]:8: note: cast {{.*}} this warning |
| 164 | + // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 165 | + // CHECK-MESSAGES: [[@LINE-2]]:8: note: cast the expression to void to silence this warning |
161 | 166 | ; |
162 | 167 |
|
163 | 168 | for (;; std::remove(nullptr, nullptr, 1)) |
164 | | - // CHECK-NOTES: [[@LINE-1]]:11: warning: the value {{.*}} should be used |
165 | | - // CHECK-NOTES: [[@LINE-2]]:11: note: cast {{.*}} this warning |
| 169 | + // CHECK-MESSAGES: [[@LINE-1]]:11: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 170 | + // CHECK-MESSAGES: [[@LINE-2]]:11: note: cast the expression to void to silence this warning |
166 | 171 | ; |
167 | 172 |
|
168 | 173 | for (auto C : "foo") |
169 | 174 | std::remove(nullptr, nullptr, 1); |
170 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
171 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 175 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 176 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
172 | 177 |
|
173 | 178 | switch (1) { |
174 | 179 | case 1: |
175 | 180 | std::remove(nullptr, nullptr, 1); |
176 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
177 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 181 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 182 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
178 | 183 | break; |
179 | 184 | default: |
180 | 185 | std::remove(nullptr, nullptr, 1); |
181 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
182 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 186 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 187 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
183 | 188 | break; |
184 | 189 | } |
185 | 190 |
|
186 | 191 | try { |
187 | 192 | std::remove(nullptr, nullptr, 1); |
188 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
189 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 193 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 194 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
190 | 195 | } catch (...) { |
191 | 196 | std::remove(nullptr, nullptr, 1); |
192 | | - // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used |
193 | | - // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning |
| 197 | + // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 198 | + // CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning |
194 | 199 | } |
195 | 200 |
|
196 | 201 | errorFunc(); |
197 | | - // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used |
198 | | - // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning |
| 202 | + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
| 203 | + // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
199 | 204 | } |
200 | 205 |
|
201 | 206 | void noWarning() { |
|
0 commit comments