================
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy -std=c++20-or-later %s readability-else-after-return
%t
+
+void g();
+
+void f() {
+ if (true) [[likely]] {
+ return;
+ } else { // comment-0
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after
'return'
+ // CHECK-FIXES: {{^}} } // comment-0
+ }
+
+ if (false) [[unlikely]] {
+ return;
+ } else { // comment-1
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after
'return'
+ // CHECK-FIXES: {{^}} } // comment-1
+ }
+
+ if (true) [[likely]]
+ return;
+ else // comment-2
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use 'else' after
'return'
+ // CHECK-FIXES: {{^}} else // comment-2
----------------
zeyi2 wrote:
If I understand correctly, the fix for this testcase should be something like:
```
if (true) [[likely]]
return
// comment-2 (preserve the comments but remove the `else`)
```
The current `CHECK-FIXES: {{^}} else // comment-2` seems to expect a line that
still contains `else`, which would contradict that. It is possible that I'm
missing something about how the fix works here. Could you clarify?
https://github.com/llvm/llvm-project/pull/184684
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits