Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 998d2f7

Browse files
committedApr 15, 2025·
[NFC][clang-tidy] Remove {{^}} clauses in some tests (3/N)
`check_clang_tidy` now matches full lines only, so `{{^}}` clauses are no longer necessary. I am splitting those changes over multiple PRs to make review easier. Numbering them but the actual order doesn't matter.
1 parent 68383fc commit 998d2f7

10 files changed

+139
-139
lines changed
 

‎clang-tools-extra/test/clang-tidy/checkers/abseil/string-find-startswith.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -29,67 +29,67 @@ std::string bar();
2929
void tests(std::string s, global_string s2, std::string_view sv) {
3030
s.find("a") == 0;
3131
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith instead of find() == 0 [abseil-string-find-startswith]
32-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, "a");{{$}}
32+
// CHECK-FIXES: absl::StartsWith(s, "a");
3333

3434
s.find(s) == 0;
3535
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
36-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, s);{{$}}
36+
// CHECK-FIXES: absl::StartsWith(s, s);
3737

3838
s.find("aaa") != 0;
3939
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
40-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, "aaa");{{$}}
40+
// CHECK-FIXES: !absl::StartsWith(s, "aaa");
4141

4242
s.find(foo(foo(bar()))) != 0;
4343
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
44-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, foo(foo(bar())));{{$}}
44+
// CHECK-FIXES: !absl::StartsWith(s, foo(foo(bar())));
4545

4646
if (s.find("....") == 0) { /* do something */ }
4747
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use absl::StartsWith
48-
// CHECK-FIXES: {{^[[:space:]]*}}if (absl::StartsWith(s, "....")) { /* do something */ }{{$}}
48+
// CHECK-FIXES: if (absl::StartsWith(s, "....")) { /* do something */ }
4949

5050
0 != s.find("a");
5151
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
52-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, "a");{{$}}
52+
// CHECK-FIXES: !absl::StartsWith(s, "a");
5353

5454
s2.find("a") == 0;
5555
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
56-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s2, "a");{{$}}
56+
// CHECK-FIXES: absl::StartsWith(s2, "a");
5757

5858
s.rfind("a", 0) == 0;
5959
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith instead of rfind() == 0 [abseil-string-find-startswith]
60-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, "a");{{$}}
60+
// CHECK-FIXES: absl::StartsWith(s, "a");
6161

6262
s.rfind(s, 0) == 0;
6363
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
64-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, s);{{$}}
64+
// CHECK-FIXES: absl::StartsWith(s, s);
6565

6666
s.rfind("aaa", 0) != 0;
6767
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
68-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, "aaa");{{$}}
68+
// CHECK-FIXES: !absl::StartsWith(s, "aaa");
6969

7070
s.rfind(foo(foo(bar())), 0) != 0;
7171
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
72-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, foo(foo(bar())));{{$}}
72+
// CHECK-FIXES: !absl::StartsWith(s, foo(foo(bar())));
7373

7474
if (s.rfind("....", 0) == 0) { /* do something */ }
7575
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use absl::StartsWith
76-
// CHECK-FIXES: {{^[[:space:]]*}}if (absl::StartsWith(s, "....")) { /* do something */ }{{$}}
76+
// CHECK-FIXES: if (absl::StartsWith(s, "....")) { /* do something */ }
7777

7878
0 != s.rfind("a", 0);
7979
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
80-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, "a");{{$}}
80+
// CHECK-FIXES: !absl::StartsWith(s, "a");
8181

8282
s2.rfind("a", 0) == 0;
8383
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
84-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s2, "a");{{$}}
84+
// CHECK-FIXES: absl::StartsWith(s2, "a");
8585

8686
sv.find("a") == 0;
8787
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
88-
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(sv, "a");{{$}}
88+
// CHECK-FIXES: absl::StartsWith(sv, "a");
8989

9090
sv.rfind("a", 0) != 0;
9191
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
92-
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(sv, "a");{{$}}
92+
// CHECK-FIXES: !absl::StartsWith(sv, "a");
9393

9494
// expressions that don't trigger the check are here.
9595
A_MACRO(s.find("a"), 0);

‎clang-tools-extra/test/clang-tidy/checkers/bugprone/reserved-identifier-c.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ void f__o__o(void);
77
void f_________oo(void);
88
void __foo(void);
99
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '__foo', which is a reserved identifier [bugprone-reserved-identifier]
10-
// CHECK-FIXES: {{^}}void foo(void);{{$}}
10+
// CHECK-FIXES: void foo(void);

‎clang-tools-extra/test/clang-tidy/checkers/bugprone/reserved-identifier.cpp

+36-36
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,35 @@
88

99
#define _MACRO(m) int m = 0
1010
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier '_MACRO', which is a reserved identifier [bugprone-reserved-identifier]
11-
// CHECK-FIXES: {{^}}#define MACRO(m) int m = 0{{$}}
11+
// CHECK-FIXES: #define MACRO(m) int m = 0
1212

1313
namespace _Ns {
1414
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: declaration uses identifier '_Ns', which is a reserved identifier [bugprone-reserved-identifier]
15-
// CHECK-FIXES: {{^}}namespace Ns {{{$}}
15+
// CHECK-FIXES: namespace Ns {
1616

1717
class _Object {
1818
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_Object', which is a reserved identifier [bugprone-reserved-identifier]
19-
// CHECK-FIXES: {{^}}class Object {{{$}}
19+
// CHECK-FIXES: class Object {
2020
int _Member;
2121
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_Member', which is a reserved identifier [bugprone-reserved-identifier]
22-
// CHECK-FIXES: {{^}} int Member;{{$}}
22+
// CHECK-FIXES: int Member;
2323
};
2424

2525
float _Global;
2626
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_Global', which is a reserved identifier [bugprone-reserved-identifier]
27-
// CHECK-FIXES: {{^}}float Global;{{$}}
27+
// CHECK-FIXES: float Global;
2828

2929
void _Function() {}
3030
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '_Function', which is a reserved identifier [bugprone-reserved-identifier]
31-
// CHECK-FIXES: {{^}}void Function() {}{{$}}
31+
// CHECK-FIXES: void Function() {}
3232

3333
using _Alias = int;
3434
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_Alias', which is a reserved identifier [bugprone-reserved-identifier]
35-
// CHECK-FIXES: {{^}}using Alias = int;{{$}}
35+
// CHECK-FIXES: using Alias = int;
3636

3737
template <typename _TemplateParam>
3838
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: declaration uses identifier '_TemplateParam', which is a reserved identifier [bugprone-reserved-identifier]
39-
// CHECK-FIXES: {{^}}template <typename TemplateParam>{{$}}
39+
// CHECK-FIXES: template <typename TemplateParam>
4040
struct S {};
4141

4242
} // namespace _Ns
@@ -45,34 +45,34 @@ struct S {};
4545

4646
#define __macro(m) int m = 0
4747
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier '__macro', which is a reserved identifier [bugprone-reserved-identifier]
48-
// CHECK-FIXES: {{^}}#define _macro(m) int m = 0{{$}}
48+
// CHECK-FIXES: #define _macro(m) int m = 0
4949

5050
namespace __ns {
5151
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: declaration uses identifier '__ns', which is a reserved identifier [bugprone-reserved-identifier]
52-
// CHECK-FIXES: {{^}}namespace ns {{{$}}
52+
// CHECK-FIXES: namespace ns {
5353
class __object {
5454
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '__object', which is a reserved identifier [bugprone-reserved-identifier]
55-
// CHECK-FIXES: {{^}}class _object {{{$}}
55+
// CHECK-FIXES: class _object {
5656
int __member;
5757
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '__member', which is a reserved identifier [bugprone-reserved-identifier]
58-
// CHECK-FIXES: {{^}} int _member;{{$}}
58+
// CHECK-FIXES: int _member;
5959
};
6060

6161
float __global;
6262
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '__global', which is a reserved identifier [bugprone-reserved-identifier]
63-
// CHECK-FIXES: {{^}}float _global;{{$}}
63+
// CHECK-FIXES: float _global;
6464

6565
void __function() {}
6666
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '__function', which is a reserved identifier [bugprone-reserved-identifier]
67-
// CHECK-FIXES: {{^}}void _function() {}{{$}}
67+
// CHECK-FIXES: void _function() {}
6868

6969
using __alias = int;
7070
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '__alias', which is a reserved identifier [bugprone-reserved-identifier]
71-
// CHECK-FIXES: {{^}}using _alias = int;{{$}}
71+
// CHECK-FIXES: using _alias = int;
7272

7373
template <typename __templateParam>
7474
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: declaration uses identifier '__templateParam', which is a reserved identifier [bugprone-reserved-identifier]
75-
// CHECK-FIXES: {{^}}template <typename _templateParam>{{$}}
75+
// CHECK-FIXES: template <typename _templateParam>
7676
struct S {};
7777

7878
} // namespace __ns
@@ -81,34 +81,34 @@ struct S {};
8181

8282
#define macro___m(m) int m = 0
8383
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier 'macro___m', which is a reserved identifier [bugprone-reserved-identifier]
84-
// CHECK-FIXES: {{^}}#define macro_m(m) int m = 0{{$}}
84+
// CHECK-FIXES: #define macro_m(m) int m = 0
8585

8686
namespace ns___n {
8787
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: declaration uses identifier 'ns___n', which is a reserved identifier [bugprone-reserved-identifier]
88-
// CHECK-FIXES: {{^}}namespace ns_n {{{$}}
88+
// CHECK-FIXES: namespace ns_n {
8989
class object___o {
9090
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier 'object___o', which is a reserved identifier [bugprone-reserved-identifier]
91-
// CHECK-FIXES: {{^}}class object_o {{{$}}
91+
// CHECK-FIXES: class object_o {
9292
int member___m;
9393
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier 'member___m', which is a reserved identifier [bugprone-reserved-identifier]
94-
// CHECK-FIXES: {{^}} int member_m;{{$}}
94+
// CHECK-FIXES: int member_m;
9595
};
9696

9797
float global___g;
9898
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier 'global___g', which is a reserved identifier [bugprone-reserved-identifier]
99-
// CHECK-FIXES: {{^}}float global_g;{{$}}
99+
// CHECK-FIXES: float global_g;
100100

101101
void function___f() {}
102102
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier 'function___f', which is a reserved identifier [bugprone-reserved-identifier]
103-
// CHECK-FIXES: {{^}}void function_f() {}{{$}}
103+
// CHECK-FIXES: void function_f() {}
104104

105105
using alias___a = int;
106106
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier 'alias___a', which is a reserved identifier [bugprone-reserved-identifier]
107-
// CHECK-FIXES: {{^}}using alias_a = int;{{$}}
107+
// CHECK-FIXES: using alias_a = int;
108108

109109
template <typename templateParam___t>
110110
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: declaration uses identifier 'templateParam___t', which is a reserved identifier [bugprone-reserved-identifier]
111-
// CHECK-FIXES: {{^}}template <typename templateParam_t>{{$}}
111+
// CHECK-FIXES: template <typename templateParam_t>
112112
struct S {};
113113

114114
} // namespace ns___n
@@ -121,55 +121,55 @@ struct S {};
121121

122122
namespace _ns {
123123
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: declaration uses identifier '_ns', which is reserved in the global namespace [bugprone-reserved-identifier]
124-
// CHECK-FIXES: {{^}}namespace ns {{{$}}
124+
// CHECK-FIXES: namespace ns {
125125
int _i;
126126
// no warning
127127
} // namespace _ns
128128
class _object {
129129
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_object', which is reserved in the global namespace [bugprone-reserved-identifier]
130-
// CHECK-FIXES: {{^}}class object {{{$}}
130+
// CHECK-FIXES: class object {
131131
int _member;
132132
// no warning
133133
};
134134
float _global;
135135
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_global', which is reserved in the global namespace [bugprone-reserved-identifier]
136-
// CHECK-FIXES: {{^}}float global;{{$}}
136+
// CHECK-FIXES: float global;
137137
void _function() {}
138138
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '_function', which is reserved in the global namespace [bugprone-reserved-identifier]
139-
// CHECK-FIXES: {{^}}void function() {}{{$}}
139+
// CHECK-FIXES: void function() {}
140140
using _alias = int;
141141
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration uses identifier '_alias', which is reserved in the global namespace [bugprone-reserved-identifier]
142-
// CHECK-FIXES: {{^}}using alias = int;{{$}}
142+
// CHECK-FIXES: using alias = int;
143143
template <typename _templateParam> // no warning, template params are not in the global namespace
144144
struct S {};
145145

146146
void _float() {}
147147
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '_float', which is reserved in the global namespace; cannot be fixed because 'float' would conflict with a keyword [bugprone-reserved-identifier]
148-
// CHECK-FIXES: {{^}}void _float() {}{{$}}
148+
// CHECK-FIXES: void _float() {}
149149

150150
#define SOME_MACRO
151151
int SOME__MACRO;
152152
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier 'SOME__MACRO', which is a reserved identifier; cannot be fixed because 'SOME_MACRO' would conflict with a macro definition [bugprone-reserved-identifier]
153-
// CHECK-FIXES: {{^}}int SOME__MACRO;{{$}}
153+
// CHECK-FIXES: int SOME__MACRO;
154154

155155
void _TWO__PROBLEMS() {}
156156
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '_TWO__PROBLEMS', which is a reserved identifier [bugprone-reserved-identifier]
157-
// CHECK-FIXES: {{^}}void TWO_PROBLEMS() {}{{$}}
157+
// CHECK-FIXES: void TWO_PROBLEMS() {}
158158
void _two__problems() {}
159159
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '_two__problems', which is a reserved identifier [bugprone-reserved-identifier]
160-
// CHECK-FIXES: {{^}}void two_problems() {}{{$}}
160+
// CHECK-FIXES: void two_problems() {}
161161

162162
int __;
163163
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '__', which is a reserved identifier; cannot be fixed automatically [bugprone-reserved-identifier]
164-
// CHECK-FIXES: {{^}}int __;{{$}}
164+
// CHECK-FIXES: int __;
165165

166166
int _________;
167167
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '_________', which is a reserved identifier; cannot be fixed automatically [bugprone-reserved-identifier]
168-
// CHECK-FIXES: {{^}}int _________;{{$}}
168+
// CHECK-FIXES: int _________;
169169

170170
int _;
171171
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '_', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier]
172-
// CHECK-FIXES: {{^}}int _;{{$}}
172+
// CHECK-FIXES: int _;
173173

174174
// This should not trigger a warning
175175
// https://github.com/llvm/llvm-project/issues/52895

‎clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
1616
Typedef1 t1;
1717
(Typedef2)t1;
1818
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: C-style casts are discouraged; use static_cast (if needed, the cast may be redundant) [google-readability-casting]
19-
// CHECK-FIXES: {{^}} static_cast<Typedef2>(t1);
19+
// CHECK-FIXES: static_cast<Typedef2>(t1);
2020
(const char*)t1;
2121
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
22-
// CHECK-FIXES: {{^}} static_cast<const char*>(t1);
22+
// CHECK-FIXES: static_cast<const char*>(t1);
2323
(Typedef1)cpc;
2424
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
25-
// CHECK-FIXES: {{^}} static_cast<Typedef1>(cpc);
25+
// CHECK-FIXES: static_cast<Typedef1>(cpc);
2626
(Typedef1)t1;
2727
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant cast to the same type
28-
// CHECK-FIXES: {{^}} t1;
28+
// CHECK-FIXES: t1;
2929

3030
char *pc = (char*)cpc;
3131
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use const_cast [google-readability-casting]
3232
// CHECK-FIXES: char *pc = const_cast<char*>(cpc);
3333
typedef char Char;
3434
Char *pChar = (Char*)pc;
3535
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}; use static_cast (if needed
36-
// CHECK-FIXES: {{^}} Char *pChar = static_cast<Char*>(pc);
36+
// CHECK-FIXES: Char *pChar = static_cast<Char*>(pc);
3737

3838
(Char)*cpc;
3939
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
40-
// CHECK-FIXES: {{^}} static_cast<Char>(*cpc);
40+
// CHECK-FIXES: static_cast<Char>(*cpc);
4141

4242
(char)*pChar;
4343
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
44-
// CHECK-FIXES: {{^}} static_cast<char>(*pChar);
44+
// CHECK-FIXES: static_cast<char>(*pChar);
4545

4646
(const char*)cpv;
4747
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast [
@@ -124,24 +124,24 @@ void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
124124

125125
e = (Enum)Enum1;
126126
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
127-
// CHECK-FIXES: {{^}} e = Enum1;
127+
// CHECK-FIXES: e = Enum1;
128128

129129
e = (Enum)e;
130130
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
131-
// CHECK-FIXES: {{^}} e = e;
131+
// CHECK-FIXES: e = e;
132132

133133
e = (Enum) e;
134134
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
135-
// CHECK-FIXES: {{^}} e = e;
135+
// CHECK-FIXES: e = e;
136136

137137
e = (Enum) (e);
138138
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
139-
// CHECK-FIXES: {{^}} e = (e);
139+
// CHECK-FIXES: e = (e);
140140

141141
static const int kZero = 0;
142142
(int)kZero;
143143
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant cast to the same type
144-
// CHECK-FIXES: {{^}} kZero;
144+
// CHECK-FIXES: kZero;
145145

146146
int b2 = static_cast<double>(b);
147147
int b3 = b;

‎clang-tools-extra/test/clang-tidy/checkers/llvm/qualified-auto.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const int *getCIntPtr();
1010
void foo() {
1111
auto NakedPtr = getIntPtr();
1212
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedPtr' can be declared as 'auto *NakedPtr'
13-
// CHECK-FIXES: {{^}} auto *NakedPtr = getIntPtr();
13+
// CHECK-FIXES: auto *NakedPtr = getIntPtr();
1414
auto NakedConstPtr = getCIntPtr();
1515
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedConstPtr' can be declared as 'const auto *NakedConstPtr'
16-
// CHECK-FIXES: {{^}} const auto *NakedConstPtr = getCIntPtr();
16+
// CHECK-FIXES: const auto *NakedConstPtr = getCIntPtr();
1717
auto *Ptr = getIntPtr();
1818
auto *ConstPtr = getCIntPtr();
1919
auto &NakedRef = *getIntPtr();

‎clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp

+34-34
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,24 @@ constexpr int Y = 1;
4040
void referenceConstexprVariable() {
4141
assert(Y > 0);
4242
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be replaced by static_assert() [misc-static-assert]
43-
// CHECK-FIXES-CXX11: {{^ }}static_assert(Y > 0, "");
44-
// CHECK-FIXES-CXX17: {{^ }}static_assert(Y > 0);
43+
// CHECK-FIXES-CXX11: static_assert(Y > 0, "");
44+
// CHECK-FIXES-CXX17: static_assert(Y > 0);
4545
}
4646

4747
void useInSizeOf() {
4848
char a = 0;
4949
assert(sizeof(a) == 1U);
5050
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be replaced by static_assert() [misc-static-assert]
51-
// CHECK-FIXES-CXX11: {{^ }}static_assert(sizeof(a) == 1U, "");
52-
// CHECK-FIXES-CXX17: {{^ }}static_assert(sizeof(a) == 1U);
51+
// CHECK-FIXES-CXX11: static_assert(sizeof(a) == 1U, "");
52+
// CHECK-FIXES-CXX17: static_assert(sizeof(a) == 1U);
5353
}
5454

5555
void useInDecltype() {
5656
char a = 0;
5757
assert(static_cast<decltype(a)>(256) == 0);
5858
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be replaced by static_assert() [misc-static-assert]
59-
// CHECK-FIXES-CXX11: {{^ }}static_assert(static_cast<decltype(a)>(256) == 0, "");
60-
// CHECK-FIXES-CXX17: {{^ }}static_assert(static_cast<decltype(a)>(256) == 0);
59+
// CHECK-FIXES-CXX11: static_assert(static_cast<decltype(a)>(256) == 0, "");
60+
// CHECK-FIXES-CXX17: static_assert(static_cast<decltype(a)>(256) == 0);
6161
}
6262

6363
}
@@ -80,28 +80,28 @@ class B {
8080
template <class T> void doSomething(T t) {
8181
assert(myfunc(1, 2));
8282
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be replaced by static_assert() [misc-static-assert]
83-
// CHECK-FIXES-CXX11: {{^ }}static_assert(myfunc(1, 2), "");
84-
// CHECK-FIXES-CXX17: {{^ }}static_assert(myfunc(1, 2));
83+
// CHECK-FIXES-CXX11: static_assert(myfunc(1, 2), "");
84+
// CHECK-FIXES-CXX17: static_assert(myfunc(1, 2));
8585

8686
assert(t.method());
87-
// CHECK-FIXES: {{^ }}assert(t.method());
87+
// CHECK-FIXES: assert(t.method());
8888

8989
assert(sizeof(T) == 123);
9090
}
9191

9292
int main() {
9393
my_macro();
9494
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
95-
// CHECK-FIXES: {{^ }}my_macro();
95+
// CHECK-FIXES: my_macro();
9696

9797
assert(myfunc(1, 2) && (3 == 4));
9898
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
99-
// CHECK-FIXES-CXX11: {{^ }}static_assert(myfunc(1, 2) && (3 == 4), "");
100-
// CHECK-FIXES-CXX17: {{^ }}static_assert(myfunc(1, 2) && (3 == 4));
99+
// CHECK-FIXES-CXX11: static_assert(myfunc(1, 2) && (3 == 4), "");
100+
// CHECK-FIXES-CXX17: static_assert(myfunc(1, 2) && (3 == 4));
101101

102102
int x = 1;
103103
assert(x == 0);
104-
// CHECK-FIXES: {{^ }}assert(x == 0);
104+
// CHECK-FIXES: assert(x == 0);
105105

106106
A a;
107107
B b;
@@ -110,55 +110,55 @@ int main() {
110110
doSomething<B>(b);
111111

112112
assert(false);
113-
// CHECK-FIXES: {{^ }}assert(false);
113+
// CHECK-FIXES: assert(false);
114114

115115
assert(False);
116-
// CHECK-FIXES: {{^ }}assert(False);
116+
// CHECK-FIXES: assert(False);
117117
assert(FALSE);
118-
// CHECK-FIXES: {{^ }}assert(FALSE);
118+
// CHECK-FIXES: assert(FALSE);
119119

120120
assert(ZERO_MACRO);
121121
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
122-
// CHECK-FIXES-CXX11: {{^ }}static_assert(ZERO_MACRO, "");
123-
// CHECK-FIXES-CXX17: {{^ }}static_assert(ZERO_MACRO);
122+
// CHECK-FIXES-CXX11: static_assert(ZERO_MACRO, "");
123+
// CHECK-FIXES-CXX17: static_assert(ZERO_MACRO);
124124

125125
assert(!"Don't report me!");
126-
// CHECK-FIXES: {{^ }}assert(!"Don't report me!");
126+
// CHECK-FIXES: assert(!"Don't report me!");
127127

128128
assert(0 && "Don't report me!");
129-
// CHECK-FIXES: {{^ }}assert(0 && "Don't report me!");
129+
// CHECK-FIXES: assert(0 && "Don't report me!");
130130

131131
assert(false && "Don't report me!");
132-
// CHECK-FIXES: {{^ }}assert(false && "Don't report me!");
132+
// CHECK-FIXES: assert(false && "Don't report me!");
133133

134134
#define NULL ((void*)0)
135135
assert(NULL && "Don't report me!");
136-
// CHECK-FIXES: {{^ }}assert(NULL && "Don't report me!");
136+
// CHECK-FIXES: assert(NULL && "Don't report me!");
137137

138138
assert(NULL == "Don't report me!");
139-
// CHECK-FIXES: {{^ }}assert(NULL == "Don't report me!");
139+
// CHECK-FIXES: assert(NULL == "Don't report me!");
140140

141141
assert("Don't report me!" == NULL);
142-
// CHECK-FIXES: {{^ }}assert("Don't report me!" == NULL);
142+
// CHECK-FIXES: assert("Don't report me!" == NULL);
143143

144144
assert(0 == "Don't report me!");
145-
// CHECK-FIXES: {{^ }}assert(0 == "Don't report me!");
145+
// CHECK-FIXES: assert(0 == "Don't report me!");
146146

147147
#define NULL ((unsigned int)0)
148148
assert(NULL && "Report me!");
149149
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
150-
// CHECK-FIXES: {{^ }}static_assert(NULL , "Report me!");
150+
// CHECK-FIXES: static_assert(NULL , "Report me!");
151151

152152
#define NULL __null
153153
assert(__null == "Don't report me!");
154-
// CHECK-FIXES: {{^ }}assert(__null == "Don't report me!");
154+
// CHECK-FIXES: assert(__null == "Don't report me!");
155155
assert(NULL == "Don't report me!");
156-
// CHECK-FIXES: {{^ }}assert(NULL == "Don't report me!");
156+
// CHECK-FIXES: assert(NULL == "Don't report me!");
157157
#undef NULL
158158

159159
assert(ZERO_MACRO && "Report me!");
160160
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
161-
// CHECK-FIXES: {{^ }}static_assert(ZERO_MACRO , "Report me!");
161+
// CHECK-FIXES: static_assert(ZERO_MACRO , "Report me!");
162162

163163
assert(0);
164164

@@ -171,19 +171,19 @@ int main() {
171171

172172
assert(10==5 && "Report me!");
173173
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
174-
// CHECK-FIXES: {{^ }}static_assert(10==5 , "Report me!");
174+
// CHECK-FIXES: static_assert(10==5 , "Report me!");
175175

176176
assert(strlen("12345") == 5);
177-
// CHECK-FIXES: {{^ }}assert(strlen("12345") == 5);
177+
// CHECK-FIXES: assert(strlen("12345") == 5);
178178

179179
#define assert(e) (__builtin_expect(!(e), 0) ? print (#e, __FILE__, __LINE__) : (void)0)
180180
assert(false);
181-
// CHECK-FIXES: {{^ }}assert(false);
181+
// CHECK-FIXES: assert(false);
182182

183183
assert(10 == 5 + 5);
184184
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
185-
// CHECK-FIXES-CXX11: {{^ }}static_assert(10 == 5 + 5, "");
186-
// CHECK-FIXES-CXX17: {{^ }}static_assert(10 == 5 + 5);
185+
// CHECK-FIXES-CXX11: static_assert(10 == 5 + 5, "");
186+
// CHECK-FIXES-CXX17: static_assert(10 == 5 + 5);
187187
#undef assert
188188

189189
return 0;

‎clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-macros.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
class Foo {};
88
class Bar {};
99
#define DEFINE(...) __VA_ARGS__
10-
// CHECK-FIXES: {{^}}#define DEFINE(...) __VA_ARGS__{{$}}
10+
// CHECK-FIXES: #define DEFINE(...) __VA_ARGS__
1111
template<typename T>
1212
void g2(std::unique_ptr<Foo> *t) {
1313
DEFINE(
14-
// CHECK-FIXES: {{^ *}}DEFINE({{$}}
14+
// CHECK-FIXES: DEFINE(
1515
auto p = std::unique_ptr<Foo>(new Foo);
1616
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
17-
// CHECK-FIXES: {{^ *}}auto p = std::unique_ptr<Foo>(new Foo);{{$}}
17+
// CHECK-FIXES: auto p = std::unique_ptr<Foo>(new Foo);
1818
t->reset(new Foo);
1919
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
20-
// CHECK-FIXES: {{^ *}}t->reset(new Foo);{{$}}
20+
// CHECK-FIXES: t->reset(new Foo);
2121
);
22-
// CHECK-FIXES: {{^ *}});{{$}}
22+
// CHECK-FIXES: );
2323
}
2424
void macro() {
2525
std::unique_ptr<Foo> *t;

‎clang-tools-extra/test/clang-tidy/checkers/modernize/unary-static-assert.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
void f_textless(int a) {
77
static_assert(sizeof(a) <= 10, "");
88
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use unary 'static_assert' when the string literal is an empty string [modernize-unary-static-assert]
9-
// CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 10 );{{$}}
9+
// CHECK-FIXES: static_assert(sizeof(a) <= 10 );
1010
FOO
11-
// CHECK-FIXES: {{^}} FOO{{$}}
11+
// CHECK-FIXES: FOO
1212
static_assert(sizeof(a) <= 17, MSG);
13-
// CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 17, MSG);{{$}}
13+
// CHECK-FIXES: static_assert(sizeof(a) <= 17, MSG);
1414
}
1515

1616
void f_with_tex(int a) {

‎clang-tools-extra/test/clang-tidy/checkers/modernize/use-bool-literals-ignore-macros.cpp

+27-27
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@
55

66
bool IntToTrue = 1;
77
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
8-
// CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
8+
// CHECK-FIXES: bool IntToTrue = true;
99

1010
bool IntToFalse(0);
1111
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: converting integer literal to bool
12-
// CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
12+
// CHECK-FIXES: bool IntToFalse(false);
1313

1414
bool LongLongToTrue{0x1LL};
1515
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: converting integer literal to bool
16-
// CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
16+
// CHECK-FIXES: bool LongLongToTrue{true};
1717

1818
bool ExplicitCStyleIntToFalse = (bool)0;
1919
// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
20-
// CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
20+
// CHECK-FIXES: bool ExplicitCStyleIntToFalse = false;
2121

2222
bool ExplicitFunctionalIntToFalse = bool(0);
2323
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: converting integer literal to bool
24-
// CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
24+
// CHECK-FIXES: bool ExplicitFunctionalIntToFalse = false;
2525

2626
bool ExplicitStaticIntToFalse = static_cast<bool>(0);
2727
// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
28-
// CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
28+
// CHECK-FIXES: bool ExplicitStaticIntToFalse = false;
2929

3030
#define TRUE_MACRO 1
31-
// CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
31+
// CHECK-FIXES: #define TRUE_MACRO 1
3232

3333
bool MacroIntToTrue = TRUE_MACRO;
34-
// CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
34+
// CHECK-FIXES: bool MacroIntToTrue = TRUE_MACRO;
3535

3636
#define FALSE_MACRO bool(0)
37-
// CHECK-FIXES: {{^}}#define FALSE_MACRO bool(0){{$}}
37+
// CHECK-FIXES: #define FALSE_MACRO bool(0)
3838

3939
bool TrueBool = true; // OK
4040

4141
bool FalseBool = bool(FALSE_MACRO);
42-
// CHECK-FIXES: {{^}}bool FalseBool = bool(FALSE_MACRO);{{$}}
42+
// CHECK-FIXES: bool FalseBool = bool(FALSE_MACRO);
4343

4444
void boolFunction(bool bar) {
4545

@@ -50,56 +50,56 @@ char Character = 0; // OK
5050
unsigned long long LongInteger = 1; // OK
5151

5252
#define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x)
53-
// CHECK-FIXES: {{^}}#define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x){{$}}
53+
// CHECK-FIXES: #define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x)
5454

5555
bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
56-
// CHECK-FIXES: {{^}}bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);{{$}}
56+
// CHECK-FIXES: bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
5757

5858
bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
59-
// CHECK-FIXES: {{^}}bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);{{$}}
59+
// CHECK-FIXES: bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
6060

6161
class FooClass {
6262
public:
6363
FooClass() : JustBool(0) {}
6464
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
65-
// CHECK-FIXES: {{^ *}}FooClass() : JustBool(false) {}{{$}}
65+
// CHECK-FIXES: FooClass() : JustBool(false) {}
6666
FooClass(int) : JustBool{0} {}
6767
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: converting integer literal to bool
68-
// CHECK-FIXES: {{^ *}}FooClass(int) : JustBool{false} {}{{$}}
68+
// CHECK-FIXES: FooClass(int) : JustBool{false} {}
6969
private:
7070
bool JustBool;
7171
bool BoolWithBraces{0};
7272
// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
73-
// CHECK-FIXES: {{^ *}}bool BoolWithBraces{false};{{$}}
73+
// CHECK-FIXES: bool BoolWithBraces{false};
7474
bool BoolFromInt = 0;
7575
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: converting integer literal to bool
76-
// CHECK-FIXES: {{^ *}}bool BoolFromInt = false;{{$}}
76+
// CHECK-FIXES: bool BoolFromInt = false;
7777
bool SimpleBool = true; // OK
7878
};
7979

8080
template<typename type>
8181
void templateFunction(type) {
8282
type TemplateType = 0;
83-
// CHECK-FIXES: {{^ *}}type TemplateType = 0;{{$}}
83+
// CHECK-FIXES: type TemplateType = 0;
8484
}
8585

8686
template<int c>
8787
void valueDependentTemplateFunction() {
8888
bool Boolean = c;
89-
// CHECK-FIXES: {{^ *}}bool Boolean = c;{{$}}
89+
// CHECK-FIXES: bool Boolean = c;
9090
}
9191

9292
template<typename type>
9393
void anotherTemplateFunction(type) {
9494
bool JustBool = 0;
9595
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: converting integer literal to bool
96-
// CHECK-FIXES: {{^ *}}bool JustBool = false;{{$}}
96+
// CHECK-FIXES: bool JustBool = false;
9797
}
9898

9999
int main() {
100100
boolFunction(1);
101101
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: converting integer literal to bool
102-
// CHECK-FIXES: {{^ *}}boolFunction(true);{{$}}
102+
// CHECK-FIXES: boolFunction(true);
103103

104104
boolFunction(false);
105105

@@ -113,7 +113,7 @@ int main() {
113113

114114
IntToTrue = 1;
115115
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: converting integer literal to bool
116-
// CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
116+
// CHECK-FIXES: IntToTrue = true;
117117
}
118118

119119
static int Value = 1;
@@ -122,26 +122,26 @@ bool Function1() {
122122
bool Result = Value == 1 ? 1 : 0;
123123
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: converting integer literal to bool
124124
// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: converting integer literal to bool
125-
// CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}}
125+
// CHECK-FIXES: bool Result = Value == 1 ? true : false;
126126
return Result;
127127
}
128128

129129
bool Function2() {
130130
return Value == 1 ? 1 : 0;
131131
// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
132132
// CHECK-MESSAGES: :[[@LINE-2]]:27: warning: converting integer literal to bool
133-
// CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}}
133+
// CHECK-FIXES: return Value == 1 ? true : false;
134134
}
135135

136136
void foo() {
137137
bool Result;
138138
Result = Value == 1 ? true : 0;
139139
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: converting integer literal to bool
140-
// CHECK-FIXES: {{^ *}}Result = Value == 1 ? true : false;{{$}}
140+
// CHECK-FIXES: Result = Value == 1 ? true : false;
141141
Result = Value == 1 ? false : bool(0);
142142
// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
143-
// CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
143+
// CHECK-FIXES: Result = Value == 1 ? false : false;
144144
Result = Value == 1 ? (bool)0 : false;
145145
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
146-
// CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
146+
// CHECK-FIXES: Result = Value == 1 ? false : false;
147147
}

‎clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-cxx98.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ struct Base {
99
struct SimpleCases : public Base {
1010
public:
1111
virtual ~SimpleCases();
12-
// CHECK-FIXES: {{^}} virtual ~SimpleCases();
12+
// CHECK-FIXES: virtual ~SimpleCases();
1313

1414
void a();
15-
// CHECK-FIXES: {{^}} void a();
15+
// CHECK-FIXES: void a();
1616

1717
virtual void b();
18-
// CHECK-FIXES: {{^}} virtual void b();
18+
// CHECK-FIXES: virtual void b();
1919
};

0 commit comments

Comments
 (0)
Please sign in to comment.