Skip to content

Commit 64dcf78

Browse files
authored
[clang-tidy][NFC] Refactor modernize-pass-by-value check code and tests (#140753)
- Deleted unused includes - Deleted useless braces - Modernized tests to use `CHECK-MESSAGES-NOT` and `CHECK-FIXES-NOT` for better readability and maintainability
1 parent dec214d commit 64dcf78

File tree

3 files changed

+1
-15
lines changed

3 files changed

+1
-15
lines changed

clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ static bool hasRValueOverload(const CXXConstructorDecl *Ctor,
166166
};
167167

168168
for (const auto *Candidate : Record->ctors()) {
169-
if (IsRValueOverload(Candidate)) {
169+
if (IsRValueOverload(Candidate))
170170
return true;
171-
}
172171
}
173172
return false;
174173
}

clang-tools-extra/clang-tidy/modernize/PassByValueCheck.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include "../ClangTidyCheck.h"
1313
#include "../utils/IncludeInserter.h"
1414

15-
#include <memory>
16-
1715
namespace clang::tidy::modernize {
1816

1917
class PassByValueCheck : public ClangTidyCheck {

clang-tools-extra/test/clang-tidy/checkers/modernize/pass-by-value.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,16 @@ struct A {
3232
Movable GlobalObj;
3333
struct B {
3434
B(const Movable &M) : M(GlobalObj) {}
35-
// CHECK-FIXES: B(const Movable &M) : M(GlobalObj) {}
3635
Movable M;
3736
};
3837

3938
// Test that a parameter with more than one reference to it won't be changed.
4039
struct C {
4140
// Tests extra-reference in body.
4241
C(const Movable &M) : M(M) { this->i = M.a; }
43-
// CHECK-FIXES: C(const Movable &M) : M(M) { this->i = M.a; }
4442

4543
// Tests extra-reference in init-list.
4644
C(const Movable &M, int) : M(M), i(M.a) {}
47-
// CHECK-FIXES: C(const Movable &M, int) : M(M), i(M.a) {}
4845
Movable M;
4946
int i;
5047
};
@@ -70,7 +67,6 @@ struct E {
7067
// Test with object that can't be moved.
7168
struct F {
7269
F(const NotMovable &NM) : NM(NM) {}
73-
// CHECK-FIXES: F(const NotMovable &NM) : NM(NM) {}
7470
NotMovable NM;
7571
};
7672

@@ -112,7 +108,6 @@ struct I {
112108
// Test that templates aren't modified.
113109
template <typename T> struct J {
114110
J(const T &M) : M(M) {}
115-
// CHECK-FIXES: J(const T &M) : M(M) {}
116111
T M;
117112
};
118113
J<Movable> j1(Movable());
@@ -129,13 +124,11 @@ struct MovableTemplateT
129124
template <class T>
130125
struct J2 {
131126
J2(const MovableTemplateT<T>& A);
132-
// CHECK-FIXES: J2(const MovableTemplateT<T>& A);
133127
MovableTemplateT<T> M;
134128
};
135129

136130
template <class T>
137131
J2<T>::J2(const MovableTemplateT<T>& A) : M(A) {}
138-
// CHECK-FIXES: J2<T>::J2(const MovableTemplateT<T>& A) : M(A) {}
139132
J2<int> j3(MovableTemplateT<int>{});
140133

141134
struct K_Movable {
@@ -182,7 +175,6 @@ struct O {
182175
// Test with a const-value parameter.
183176
struct P {
184177
P(const Movable M) : M(M) {}
185-
// CHECK-FIXES: P(const Movable M) : M(M) {}
186178
Movable M;
187179
};
188180

@@ -215,7 +207,6 @@ struct R {
215207
// Test with rvalue parameter.
216208
struct S {
217209
S(Movable &&M) : M(M) {}
218-
// CHECK-FIXES: S(Movable &&M) : M(M) {}
219210
Movable M;
220211
};
221212

@@ -225,13 +216,11 @@ template <typename T, int N> struct array { T A[N]; };
225216
// cause problems with performance-move-const-arg, as it will revert it.
226217
struct T {
227218
T(array<int, 10> a) : a_(a) {}
228-
// CHECK-FIXES: T(array<int, 10> a) : a_(a) {}
229219
array<int, 10> a_;
230220
};
231221

232222
struct U {
233223
U(const POD &M) : M(M) {}
234-
// CHECK-FIXES: U(const POD &M) : M(M) {}
235224
POD M;
236225
};
237226

0 commit comments

Comments
 (0)