Skip to content

Commit cfb7875

Browse files
[clang-tidy] Add some more tests
1 parent 02aa926 commit cfb7875

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %check_clang_tidy -std=c++20-or-later %s readability-inconsistent-ifelse-braces %t
2+
3+
void do_something(const char *) {}
4+
5+
// Positive tests.
6+
void f(bool b) {
7+
if (b) [[likely]] do_something("if-same-line");
8+
else {
9+
}
10+
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: <message> [readability-inconsistent-ifelse-braces]
11+
// CHECK-FIXES: if (b) { {{[[][[]}}likely{{[]][]]}} do_something("if-same-line");
12+
// CHECK-FIXES: } else {
13+
}
14+
15+
// Negative tests.
16+
/*
17+
void g(bool b) {
18+
if (b) {
19+
return;
20+
}
21+
22+
if (b) { [[likely]]
23+
return;
24+
}
25+
26+
if (b) { [[unlikely]]
27+
return;
28+
}
29+
30+
if (b) [[likely]]
31+
return;
32+
33+
if (b) [[unlikely]]
34+
return;
35+
} */

0 commit comments

Comments
 (0)