1// RUN: %check_clang_tidy %s readability-else-after-return %t -- \
2// RUN: -config='{CheckOptions: { \
3// RUN: readability-else-after-return.WarnOnUnfixable: false, \
4// RUN: }}'
5
6int h(int);
7
8int lifeTimeExtensionTests(int a) {
9 if (a > 0) {
10 return a;
11 } else {
12 // CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
13 int b = 0;
14 h(b);
15 }
16 if (int b = a) {
17 return a;
18 } else {
19 // CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
20 b++;
21 }
22 if (int b = a) { // comment-0
23 // CHECK-FIXES: {{^}} int b = a;
24 // CHECK-FIXES-NEXT: {{^}}if (b) { // comment-0
25 return a;
26 } else { // comment-0
27 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
28 // CHECK-FIXES: {{^}} } // comment-0
29 return b;
30 }
31}
32

source code of clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-no-warn.cpp