[clang-tools-extra] [clang-tidy] Fix readability-else-after-return for if statements appear in unbraced switch case labels (PR #181878)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 02:03:50 PST 2026
================
@@ -312,3 +312,19 @@ void testPPConditionals() {
}
#endif
}
+
+void testSwitchCaseWithoutInnerCompound(int i, bool b) {
+ switch (i) {
+ case 0:
+ if (b) {
+ return;
+ } else {
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'return'
+ // CHECK-FIXES: {{^}} }
----------------
zwuis wrote:
This check doesn't work. If there is no fix-it, line 325 will be matched. You could refer to other tests in this file.
https://github.com/llvm/llvm-project/pull/181878
More information about the cfe-commits
mailing list