Skip to content

Commit 68383fc

Browse files
authored
[NFC][clang-tidy] Remove {{^}} clauses in some tests (1/N) (llvm#134737)
`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 1545f11 commit 68383fc

11 files changed

+274
-276
lines changed

clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy --match-partial-fixes %s performance-for-range-copy %t -- -- -fno-delayed-template-parsing
1+
// RUN: %check_clang_tidy %s performance-for-range-copy %t -- -- -fno-delayed-template-parsing
22

33
namespace std {
44

@@ -79,7 +79,7 @@ template <typename T>
7979
void uninstantiated() {
8080
for (const S S1 : View<Iterator<S>>()) {}
8181
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is not a reference type; this creates a copy in each iteration; consider making this a reference [performance-for-range-copy]
82-
// CHECK-FIXES: {{^}} for (const S& S1 : View<Iterator<S>>()) {}
82+
// CHECK-FIXES: for (const S& S1 : View<Iterator<S>>()) {}
8383

8484
// Don't warn on dependent types.
8585
for (const T t1 : View<Iterator<T>>()) {
@@ -90,15 +90,15 @@ template <typename T>
9090
void instantiated() {
9191
for (const S S2 : View<Iterator<S>>()) {}
9292
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is {{.*}}
93-
// CHECK-FIXES: {{^}} for (const S& S2 : View<Iterator<S>>()) {}
93+
// CHECK-FIXES: for (const S& S2 : View<Iterator<S>>()) {}
9494

9595
for (const auto [X, Y] : View<Iterator<Point>>()) {}
9696
// CHECK-MESSAGES: [[@LINE-1]]:19: warning: the loop variable's type is
97-
// CHECK-FIXES: {{^}} for (const auto& [X, Y] : View<Iterator<Point>>()) {}
97+
// CHECK-FIXES: for (const auto& [X, Y] : View<Iterator<Point>>()) {}
9898

9999
for (const T T2 : View<Iterator<T>>()) {}
100100
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is {{.*}}
101-
// CHECK-FIXES: {{^}} for (const T& T2 : View<Iterator<T>>()) {}
101+
// CHECK-FIXES: for (const T& T2 : View<Iterator<T>>()) {}
102102
}
103103

104104
template <typename T>
@@ -311,10 +311,8 @@ View<Iterator<S>> createView(S) { return View<Iterator<S>>(); }
311311

312312
void positiveValueIteratorUsedElseWhere() {
313313
for (const S SS : createView(*ValueReturningIterator<S>())) {
314-
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is not
315-
// a reference type; this creates a copy in each iteration; consider making
316-
// this a reference [performance-for-range-copy] CHECK-FIXES: for (const S&
317-
// SS : createView(*ValueReturningIterator<S>())) {
314+
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is not a reference type; this creates a copy in each iteration; consider making this a reference [performance-for-range-copy]
315+
// CHECK-FIXES: for (const S& SS : createView(*ValueReturningIterator<S>())) {
318316
}
319317
}
320318

clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-algorithm.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,83 +69,83 @@ template <typename T> void f(const T &t) {
6969
std::set<int> s;
7070
find(s.begin(), s.end(), 46);
7171
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
72-
// CHECK-FIXES: {{^ }}s.find(46);{{$}}
72+
// CHECK-FIXES: s.find(46);
7373

7474
find(t.begin(), t.end(), 46);
75-
// CHECK-FIXES: {{^ }}find(t.begin(), t.end(), 46);{{$}}
75+
// CHECK-FIXES: find(t.begin(), t.end(), 46);
7676
}
7777

7878
int main() {
7979
std::set<int> s;
8080
auto it = std::find(s.begin(), s.end(), 43);
8181
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: this STL algorithm call should be replaced with a container method [performance-inefficient-algorithm]
82-
// CHECK-FIXES: {{^ }}auto it = s.find(43);{{$}}
82+
// CHECK-FIXES: auto it = s.find(43);
8383
auto c = count(s.begin(), s.end(), 43);
8484
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be
85-
// CHECK-FIXES: {{^ }}auto c = s.count(43);{{$}}
85+
// CHECK-FIXES: auto c = s.count(43);
8686

8787
#define SECOND(x, y, z) y
8888
SECOND(q,std::count(s.begin(), s.end(), 22),w);
8989
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be
90-
// CHECK-FIXES: {{^ }}SECOND(q,s.count(22),w);{{$}}
90+
// CHECK-FIXES: SECOND(q,s.count(22),w);
9191

9292
it = find_if(s.begin(), s.end(), [](int) { return false; });
9393

9494
std::multiset<int> ms;
9595
find(ms.begin(), ms.end(), 46);
9696
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
97-
// CHECK-FIXES: {{^ }}ms.find(46);{{$}}
97+
// CHECK-FIXES: ms.find(46);
9898

9999
const std::multiset<int> &msref = ms;
100100
find(msref.begin(), msref.end(), 46);
101101
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
102-
// CHECK-FIXES: {{^ }}msref.find(46);{{$}}
102+
// CHECK-FIXES: msref.find(46);
103103

104104
std::multiset<int> *msptr = &ms;
105105
find(msptr->begin(), msptr->end(), 46);
106106
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
107-
// CHECK-FIXES: {{^ }}msptr->find(46);{{$}}
107+
// CHECK-FIXES: msptr->find(46);
108108

109109
it = std::find(s.begin(), s.end(), 43, std::greater<int>());
110110
// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: different comparers used in the algorithm and the container [performance-inefficient-algorithm]
111111

112112
FIND_IN_SET(s);
113113
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
114-
// CHECK-FIXES: {{^ }}FIND_IN_SET(s);{{$}}
114+
// CHECK-FIXES: FIND_IN_SET(s);
115115

116116
f(s);
117117

118118
std::unordered_set<int> us;
119119
lower_bound(us.begin(), us.end(), 10);
120-
// CHECK-FIXES: {{^ }}lower_bound(us.begin(), us.end(), 10);{{$}}
120+
// CHECK-FIXES: lower_bound(us.begin(), us.end(), 10);
121121
find(us.begin(), us.end(), 10);
122122
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
123-
// CHECK-FIXES: {{^ }}us.find(10);{{$}}
123+
// CHECK-FIXES: us.find(10);
124124

125125
std::unordered_multiset<int> ums;
126126
find(ums.begin(), ums.end(), 10);
127127
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
128-
// CHECK-FIXES: {{^ }}ums.find(10);{{$}}
128+
// CHECK-FIXES: ums.find(10);
129129

130130
std::map<int, int> intmap;
131131
find(intmap.begin(), intmap.end(), 46);
132132
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
133-
// CHECK-FIXES: {{^ }}find(intmap.begin(), intmap.end(), 46);{{$}}
133+
// CHECK-FIXES: find(intmap.begin(), intmap.end(), 46);
134134

135135
std::multimap<int, int> intmmap;
136136
find(intmmap.begin(), intmmap.end(), 46);
137137
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
138-
// CHECK-FIXES: {{^ }}find(intmmap.begin(), intmmap.end(), 46);{{$}}
138+
// CHECK-FIXES: find(intmmap.begin(), intmmap.end(), 46);
139139

140140
std::unordered_map<int, int> umap;
141141
find(umap.begin(), umap.end(), 46);
142142
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
143-
// CHECK-FIXES: {{^ }}find(umap.begin(), umap.end(), 46);{{$}}
143+
// CHECK-FIXES: find(umap.begin(), umap.end(), 46);
144144

145145
std::unordered_multimap<int, int> ummap;
146146
find(ummap.begin(), ummap.end(), 46);
147147
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
148-
// CHECK-FIXES: {{^ }}find(ummap.begin(), ummap.end(), 46);{{$}}
148+
// CHECK-FIXES: find(ummap.begin(), ummap.end(), 46);
149149
}
150150

151151
struct Value {
@@ -162,5 +162,5 @@ struct Ordering {
162162
void g(std::set<Value, Ordering> container, int value) {
163163
lower_bound(container.begin(), container.end(), value, Ordering());
164164
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
165-
// CHECK-FIXES: {{^ }}lower_bound(container.begin(), container.end(), value, Ordering());{{$}}
165+
// CHECK-FIXES: lower_bound(container.begin(), container.end(), value, Ordering());
166166
}

clang-tools-extra/test/clang-tidy/checkers/performance/trivially-destructible.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct NotTriviallyDestructible1 : TriviallyDestructible2 {
2121

2222
NotTriviallyDestructible1::~NotTriviallyDestructible1() = default; // to-be-removed
2323
// CHECK-MESSAGES: :[[@LINE-1]]:28: note: destructor definition is here
24-
// CHECK-FIXES: {{^}}// to-be-removed
24+
// CHECK-FIXES: // to-be-removed
2525

2626
// Don't emit for class template with type-dependent fields.
2727
template <class T>
@@ -57,7 +57,7 @@ struct MaybeTriviallyDestructible1<T *> {
5757
template <class T>
5858
MaybeTriviallyDestructible1<T *>::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
5959
// CHECK-MESSAGES: :[[@LINE-1]]:35: note: destructor definition is here
60-
// CHECK-FIXES: {{^}}// to-be-removed
60+
// CHECK-FIXES: // to-be-removed
6161

6262
// Emit for explicit specializations.
6363
template <>
@@ -69,7 +69,7 @@ struct MaybeTriviallyDestructible1<double>: TriviallyDestructible1 {
6969

7070
MaybeTriviallyDestructible1<double>::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
7171
// CHECK-MESSAGES: :[[@LINE-1]]:38: note: destructor definition is here
72-
// CHECK-FIXES: {{^}}// to-be-removed
72+
// CHECK-FIXES: // to-be-removed
7373

7474
struct NotTriviallyDestructible2 {
7575
virtual ~NotTriviallyDestructible2();

0 commit comments

Comments
 (0)