================
@@ -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
----------------
localspook wrote:

The check is being conservative because of the declaration in the `else` 
branch. There's an option to control this:
https://github.com/llvm/llvm-project/blob/babead29c3fb2c44b85e8fd2f269ee56b69cafb2/clang-tools-extra/docs/clang-tidy/checks/readability/else-after-return.rst?plain=1#L66-L71

https://github.com/llvm/llvm-project/pull/184684
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to