You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/performance/lost-std-move.cpp
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,12 @@ void f_extern()
62
62
f(ptr);
63
63
}
64
64
65
+
std::shared_ptr<int> global;
66
+
voidf_global()
67
+
{
68
+
f(global);
69
+
}
70
+
65
71
voidf_local()
66
72
{
67
73
std::shared_ptr<int> ptr;
@@ -140,3 +146,36 @@ int f_macro()
140
146
std::shared_ptr<int> ptr;
141
147
returnFUN(ptr);
142
148
}
149
+
150
+
voidf_lambda_ref()
151
+
{
152
+
std::shared_ptr<int> ptr;
153
+
auto Lambda = [&ptr]() mutable {
154
+
f(ptr);
155
+
};
156
+
Lambda();
157
+
}
158
+
159
+
voidf_lambda()
160
+
{
161
+
std::shared_ptr<int> ptr;
162
+
auto Lambda = [ptr]() mutable {
163
+
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
164
+
// CHECK-FIXES: auto Lambda = [Mov]() mutable {
165
+
// Note: No fix, because a fix requires c++14.
166
+
f(ptr);
167
+
};
168
+
Lambda();
169
+
}
170
+
171
+
voidf_lambda_assign()
172
+
{
173
+
std::shared_ptr<int> ptr;
174
+
auto Lambda = [ptr = ptr]() mutable {
175
+
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
0 commit comments