Skip to content

Commit de3acbf

Browse files
[clang-tidy] Update diagnostic message
1 parent eb72006 commit de3acbf

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

clang-tools-extra/clang-tidy/readability/InconsistentIfElseBracesCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void InconsistentIfElseBracesCheck::emitDiagnostic(
8383
const utils::BraceInsertionHints Hints =
8484
utils::getBraceInsertionsHints(S, LangOpts, SM, StartLoc, EndLocHint);
8585
assert(Hints && Hints.offersFixIts() && "Expected hints or fix-its");
86-
diag(Hints.DiagnosticPos, "<message>")
86+
diag(Hints.DiagnosticPos, "statement should have braces")
8787
<< Hints.openingBraceFixIt() << Hints.closingBraceFixIt();
8888
} else {
8989
diag(StartLoc, "<message-for-macro-expansions>") << StartLoc.isMacroID();

clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-ifelse-braces-attributes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ void f(bool b) {
55
if (b) [[likely]] return;
66
else {
77
}
8-
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
8+
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
99
// CHECK-FIXES: if (b) { {{[[][[]}}likely{{[]][]]}} return;
1010
// CHECK-FIXES: } else {
1111

1212
if (b) {
1313
} else [[unlikely]]
1414
return;
15-
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
15+
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
1616
// CHECK-FIXES: } else { {{[[][[]}}unlikely{{[]][]]}}
1717
}
1818

clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-ifelse-braces-consteval-if.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void f() {
1010
do_something("if-single-line");
1111
else {
1212
}
13-
// CHECK-MESSAGES: :[[@LINE-4]]:21: warning: <message> [readability-inconsistent-ifelse-braces]
13+
// CHECK-MESSAGES: :[[@LINE-4]]:21: warning: statement should have braces [readability-inconsistent-ifelse-braces]
1414
// CHECK-FIXES: if (cond("if1")) {
1515
// CHECK-FIXES: } else {
1616
}
@@ -20,14 +20,14 @@ void f() {
2020
do_something("if-single-line");
2121
else {
2222
}
23-
// CHECK-MESSAGES: :[[@LINE-4]]:21: warning: <message> [readability-inconsistent-ifelse-braces]
23+
// CHECK-MESSAGES: :[[@LINE-4]]:21: warning: statement should have braces [readability-inconsistent-ifelse-braces]
2424
// CHECK-FIXES: if (cond("if2")) {
2525
// CHECK-FIXES: } else {
2626
} else {
2727
if (cond("if2.1")) {
2828
} else
2929
do_something("else-single-line");
30-
// CHECK-MESSAGES: :[[@LINE-2]]:11: warning: <message> [readability-inconsistent-ifelse-braces]
30+
// CHECK-MESSAGES: :[[@LINE-2]]:11: warning: statement should have braces [readability-inconsistent-ifelse-braces]
3131
// CHECK-FIXES: } else {
3232
// CHECK-FIXES: }
3333
}

clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-ifelse-braces-constexpr-if.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ void f() {
88
if constexpr (cond("if0") /*comment*/) do_something("if-same-line");
99
else {
1010
}
11-
// CHECK-MESSAGES: :[[@LINE-3]]:41: warning: <message> [readability-inconsistent-ifelse-braces]
11+
// CHECK-MESSAGES: :[[@LINE-3]]:41: warning: statement should have braces [readability-inconsistent-ifelse-braces]
1212
// CHECK-FIXES: if constexpr (cond("if0") /*comment*/) { do_something("if-same-line");
1313
// CHECK-FIXES: } else {
1414

1515
if constexpr (cond("if0.1") /*comment*/) {
1616
} else do_something("else-same-line");
17-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
17+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
1818
// CHECK-FIXES: } else { do_something("else-same-line");
1919
// CHECK-FIXES: }
2020

2121
if constexpr (cond("if1"))
2222
do_something("if-single-line");
2323
else {
2424
}
25-
// CHECK-MESSAGES: :[[@LINE-4]]:29: warning: <message> [readability-inconsistent-ifelse-braces]
25+
// CHECK-MESSAGES: :[[@LINE-4]]:29: warning: statement should have braces [readability-inconsistent-ifelse-braces]
2626
// CHECK-FIXES: if constexpr (cond("if1")) {
2727
// CHECK-FIXES: } else {
2828

2929
if constexpr (cond("if1.1")) {
3030
} else
3131
do_something("else-single-line");
32-
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
32+
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
3333
// CHECK-FIXES: } else {
3434
// CHECK-FIXES: }
3535

@@ -38,38 +38,38 @@ void f() {
3838
do_something("if-multi-line");
3939
else {
4040
}
41-
// CHECK-MESSAGES: :[[@LINE-5]]:41: warning: <message> [readability-inconsistent-ifelse-braces]
41+
// CHECK-MESSAGES: :[[@LINE-5]]:41: warning: statement should have braces [readability-inconsistent-ifelse-braces]
4242
// CHECK-FIXES: if constexpr (cond("if2") /*comment*/) {
4343
// CHECK-FIXES: } else {
4444

4545
if constexpr (cond("if2.1") /*comment*/) {
4646
} else
4747
// some comment
4848
do_something("else-multi-line");
49-
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
49+
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
5050
// CHECK-FIXES: } else {
5151
// CHECK-FIXES: }
5252

5353
if constexpr (cond("if3")) do_something("elseif-same-line");
5454
else if constexpr (cond("if3")) {
5555
} else {
5656
}
57-
// CHECK-MESSAGES: :[[@LINE-4]]:29: warning: <message> [readability-inconsistent-ifelse-braces]
57+
// CHECK-MESSAGES: :[[@LINE-4]]:29: warning: statement should have braces [readability-inconsistent-ifelse-braces]
5858
// CHECK-FIXES: if constexpr (cond("if3")) { do_something("elseif-same-line");
5959
// CHECK-FIXES: } else if constexpr (cond("if3")) {
6060

6161
if constexpr (cond("if3.1")) {
6262
} else if constexpr (cond("if3.1")) do_something("elseif-same-line");
6363
else {
6464
}
65-
// CHECK-MESSAGES: :[[@LINE-3]]:38: warning: <message> [readability-inconsistent-ifelse-braces]
65+
// CHECK-MESSAGES: :[[@LINE-3]]:38: warning: statement should have braces [readability-inconsistent-ifelse-braces]
6666
// CHECK-FIXES: } else if constexpr (cond("if3.1")) { do_something("elseif-same-line");
6767
// CHECK-FIXES: } else {
6868

6969
if constexpr (cond("if3.2")) {
7070
} else if constexpr (cond("if3.2")) {
7171
} else do_something("else-same-line");
72-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
72+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
7373
// CHECK-FIXES: } else { do_something("else-same-line");
7474
// CHECK-FIXES: }
7575

@@ -80,8 +80,8 @@ void f() {
8080
}
8181
else {
8282
}
83-
// CHECK-MESSAGES: :[[@LINE-7]]:35: warning: <message> [readability-inconsistent-ifelse-braces]
84-
// CHECK-MESSAGES: :[[@LINE-7]]:37: warning: <message> [readability-inconsistent-ifelse-braces]
83+
// CHECK-MESSAGES: :[[@LINE-7]]:35: warning: statement should have braces [readability-inconsistent-ifelse-braces]
84+
// CHECK-MESSAGES: :[[@LINE-7]]:37: warning: statement should have braces [readability-inconsistent-ifelse-braces]
8585
// CHECK-FIXES: if constexpr (cond("if4-outer")) {
8686
// CHECK-FIXES: if constexpr (cond("if4-inner")) {
8787
// CHECK-FIXES: } else {
@@ -91,14 +91,14 @@ void f() {
9191
do_something("if-single-line");
9292
else if constexpr (cond("if5")) {
9393
}
94-
// CHECK-MESSAGES: :[[@LINE-4]]:29: warning: <message> [readability-inconsistent-ifelse-braces]
94+
// CHECK-MESSAGES: :[[@LINE-4]]:29: warning: statement should have braces [readability-inconsistent-ifelse-braces]
9595
// CHECK-FIXES: if constexpr (cond("if5")) {
9696
// CHECK-FIXES: } else if constexpr (cond("if5")) {
9797

9898
if constexpr (cond("if5.1")) {
9999
} else if constexpr (cond("if5.1"))
100100
do_something("elseif-single-line");
101-
// CHECK-MESSAGES: :[[@LINE-2]]:38: warning: <message> [readability-inconsistent-ifelse-braces]
101+
// CHECK-MESSAGES: :[[@LINE-2]]:38: warning: statement should have braces [readability-inconsistent-ifelse-braces]
102102
// CHECK-FIXES: } else if constexpr (cond("if5.1")) {
103103
// CHECK-FIXES: }
104104
}

clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-ifelse-braces.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ void f() {
1111
if (cond("if0") /*comment*/) do_something("if-same-line");
1212
else {
1313
}
14-
// CHECK-MESSAGES: :[[@LINE-3]]:31: warning: <message> [readability-inconsistent-ifelse-braces]
14+
// CHECK-MESSAGES: :[[@LINE-3]]:31: warning: statement should have braces [readability-inconsistent-ifelse-braces]
1515
// CHECK-FIXES: if (cond("if0") /*comment*/) { do_something("if-same-line");
1616
// CHECK-FIXES: } else {
1717

1818
if (cond("if0.1") /*comment*/) {
1919
} else do_something("else-same-line");
20-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
20+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
2121
// CHECK-FIXES: } else { do_something("else-same-line");
2222
// CHECK-FIXES: }
2323

2424
if (cond("if1"))
2525
do_something("if-single-line");
2626
else {
2727
}
28-
// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: <message> [readability-inconsistent-ifelse-braces]
28+
// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: statement should have braces [readability-inconsistent-ifelse-braces]
2929
// CHECK-FIXES: if (cond("if1")) {
3030
// CHECK-FIXES: } else {
3131

3232
if (cond("if1.1")) {
3333
} else
3434
do_something("else-single-line");
35-
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
35+
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
3636
// CHECK-FIXES: } else {
3737
// CHECK-FIXES: }
3838

@@ -41,38 +41,38 @@ void f() {
4141
do_something("if-multi-line");
4242
else {
4343
}
44-
// CHECK-MESSAGES: :[[@LINE-5]]:31: warning: <message> [readability-inconsistent-ifelse-braces]
44+
// CHECK-MESSAGES: :[[@LINE-5]]:31: warning: statement should have braces [readability-inconsistent-ifelse-braces]
4545
// CHECK-FIXES: if (cond("if2") /*comment*/) {
4646
// CHECK-FIXES: } else {
4747

4848
if (cond("if2.1") /*comment*/) {
4949
} else
5050
// some comment
5151
do_something("else-multi-line");
52-
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
52+
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
5353
// CHECK-FIXES: } else {
5454
// CHECK-FIXES: }
5555

5656
if (cond("if3")) do_something("elseif-same-line");
5757
else if (cond("if3")) {
5858
} else {
5959
}
60-
// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: <message> [readability-inconsistent-ifelse-braces]
60+
// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: statement should have braces [readability-inconsistent-ifelse-braces]
6161
// CHECK-FIXES: if (cond("if3")) { do_something("elseif-same-line");
6262
// CHECK-FIXES: } else if (cond("if3")) {
6363

6464
if (cond("if3.1")) {
6565
} else if (cond("if3.1")) do_something("elseif-same-line");
6666
else {
6767
}
68-
// CHECK-MESSAGES: :[[@LINE-3]]:28: warning: <message> [readability-inconsistent-ifelse-braces]
68+
// CHECK-MESSAGES: :[[@LINE-3]]:28: warning: statement should have braces [readability-inconsistent-ifelse-braces]
6969
// CHECK-FIXES: } else if (cond("if3.1")) { do_something("elseif-same-line");
7070
// CHECK-FIXES: } else {
7171

7272
if (cond("if3.2")) {
7373
} else if (cond("if3.2")) {
7474
} else do_something("else-same-line");
75-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
75+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
7676
// CHECK-FIXES: } else { do_something("else-same-line");
7777
// CHECK-FIXES: }
7878

@@ -83,8 +83,8 @@ void f() {
8383
}
8484
else {
8585
}
86-
// CHECK-MESSAGES: :[[@LINE-7]]:25: warning: <message> [readability-inconsistent-ifelse-braces]
87-
// CHECK-MESSAGES: :[[@LINE-7]]:27: warning: <message> [readability-inconsistent-ifelse-braces]
86+
// CHECK-MESSAGES: :[[@LINE-7]]:25: warning: statement should have braces [readability-inconsistent-ifelse-braces]
87+
// CHECK-MESSAGES: :[[@LINE-7]]:27: warning: statement should have braces [readability-inconsistent-ifelse-braces]
8888
// CHECK-FIXES: if (cond("if4-outer")) {
8989
// CHECK-FIXES: if (cond("if4-inner")) {
9090
// CHECK-FIXES: } else {
@@ -94,27 +94,27 @@ void f() {
9494
do_something("if-single-line");
9595
else if (cond("if5")) {
9696
}
97-
// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: <message> [readability-inconsistent-ifelse-braces]
97+
// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: statement should have braces [readability-inconsistent-ifelse-braces]
9898
// CHECK-FIXES: if (cond("if5")) {
9999
// CHECK-FIXES: } else if (cond("if5")) {
100100

101101
if (cond("if5.1")) {
102102
} else if (cond("if5.1"))
103103
do_something("elseif-single-line");
104-
// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: <message> [readability-inconsistent-ifelse-braces]
104+
// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: statement should have braces [readability-inconsistent-ifelse-braces]
105105
// CHECK-FIXES: } else if (cond("if5.1")) {
106106
// CHECK-FIXES: }
107107

108108
if (MACRO_COND("if6")) MACRO_FUN;
109109
else {
110110
}
111-
// CHECK-MESSAGES: :[[@LINE-3]]:20: warning: <message> [readability-inconsistent-ifelse-braces]
111+
// CHECK-MESSAGES: :[[@LINE-3]]:25: warning: statement should have braces [readability-inconsistent-ifelse-braces]
112112
// CHECK-FIXES: if (MACRO_COND("if6")) { MACRO_FUN;
113113
// CHECK-FIXES: } else {
114114

115115
if (MACRO_COND("if6")) {
116116
} else MACRO_FUN;
117-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
117+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should have braces [readability-inconsistent-ifelse-braces]
118118
// CHECK-FIXES: } else { MACRO_FUN;
119119
}
120120

0 commit comments

Comments
 (0)