summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp
diff options
context:
space:
mode:
authorMalcolm Parsons <malcolm.parsons@gmail.com>2017-01-12 19:20:35 +0000
committerMalcolm Parsons <malcolm.parsons@gmail.com>2017-01-12 19:20:35 +0000
commit6b3e27219eae71d02d4c530cdbafdd9ac39e9a6f (patch)
tree2378701ea6a84d0e2e49711d8bcfb9289e411f0f /clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp
parentbec58f903452b733589b75c5aa3e7876e9e593e6 (diff)
downloadbcm5719-llvm-6b3e27219eae71d02d4c530cdbafdd9ac39e9a6f.tar.gz
bcm5719-llvm-6b3e27219eae71d02d4c530cdbafdd9ac39e9a6f.zip
[clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value
Summary: rL270567 excluded trivially copyable types from being moved by modernize-pass-by-value, but it didn't exclude references to them. Change types used in the tests to not be trivially copyable. Reviewers: madsravn, aaron.ballman, alexfh Subscribers: JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D28614 llvm-svn: 291796
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp b/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp
index bfb853096e0..eb9a3052998 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp
@@ -2,8 +2,15 @@
namespace {
// POD types are trivially move constructible.
+struct POD {
+ int a, b, c;
+};
+
struct Movable {
int a, b, c;
+ Movable() = default;
+ Movable(const Movable &) {}
+ Movable(Movable &&) {}
};
struct NotMovable {
@@ -147,7 +154,8 @@ template <typename T> struct N {
// Test with value parameter.
struct O {
O(Movable M) : M(M) {}
- // CHECK-FIXES: O(Movable M) : M(M) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+ // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
Movable M;
};
@@ -179,7 +187,8 @@ typedef ::Movable RMovable;
}
struct R {
R(ns_R::RMovable M) : M(M) {}
- // CHECK-FIXES: R(ns_R::RMovable M) : M(M) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+ // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {}
ns_R::RMovable M;
};
@@ -199,3 +208,8 @@ struct T {
// CHECK-FIXES: T(array<int, 10> a) : a_(a) {}
array<int, 10> a_;
};
+
+struct U {
+ U(const POD &M) : M(M) {}
+ POD M;
+};
OpenPOWER on IntegriCloud