diff options
| author | Mads Ravn <madsravn@gmail.com> | 2016-05-24 15:13:44 +0000 |
|---|---|---|
| committer | Mads Ravn <madsravn@gmail.com> | 2016-05-24 15:13:44 +0000 |
| commit | 28cc243930329b963f6d2b5c041a656f45ed6eff (patch) | |
| tree | 04b8a27ce071934fe11f8752544e16b34374c99b /clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp | |
| parent | a7d19414da5751df6839511042a0d56e34bdf0e8 (diff) | |
| download | bcm5719-llvm-28cc243930329b963f6d2b5c041a656f45ed6eff.tar.gz bcm5719-llvm-28cc243930329b963f6d2b5c041a656f45ed6eff.zip | |
[clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
Adding to revision 270565. The lit-style test was wrong. This is being fixed by this commit.
This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731
This is the code review on phabricator: http://reviews.llvm.org/D20365
llvm-svn: 270567
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.cpp | 34 |
1 files changed, 16 insertions, 18 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 b45fd83ee55..d7c9d141b4b 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 @@ -1,9 +1,7 @@ -#include <utility> -#include <array> - // RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 -fno-delayed-template-parsing // CHECK-FIXES: #include <utility> +#include <array> namespace { // POD types are trivially move constructible. @@ -20,7 +18,7 @@ struct NotMovable { } struct A { - A(Movable M) : M(std::move(M)) {} + A(const Movable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value] // CHECK-FIXES: A(Movable M) : M(std::move(M)) {} Movable M; @@ -49,17 +47,17 @@ struct C { // Test that both declaration and definition are updated. struct D { - D(Movable M); + D(const Movable &M); // CHECK-FIXES: D(Movable M); Movable M; }; -D::D(Movable M) : M(std::move(M)) {} +D::D(const Movable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move // CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {} // Test with default parameter. struct E { - E(Movable M = Movable()) : M(std::move(M)) {} + E(const Movable &M = Movable()) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {} Movable M; @@ -74,11 +72,11 @@ struct F { // Test unnamed parameter in declaration. struct G { - G(Movable ); + G(const Movable &); // CHECK-FIXES: G(Movable ); Movable M; }; -G::G(Movable M) : M(std::move(M)) {} +G::G(const Movable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move // CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {} @@ -87,12 +85,12 @@ namespace ns_H { typedef ::Movable HMovable; } struct H { - H(ns_H::HMovable M); + H(const ns_H::HMovable &M); // CHECK-FIXES: H(ns_H::HMovable M); ns_H::HMovable M; }; using namespace ns_H; -H::H(HMovable M) : M(std::move(M)) {} +H::H(const HMovable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move // CHECK-FIXES: H(HMovable M) : M(std::move(M)) {} @@ -125,14 +123,14 @@ struct K_Movable { // Test with movable type with an user defined move constructor. struct K { - K(K_Movable M) : M(std::move(M)) {} + K(const K_Movable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {} K_Movable M; }; template <typename T> struct L { - L(Movable M) : M(std::move(M)) {} + L(const Movable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move // CHECK-FIXES: L(Movable M) : M(std::move(M)) {} Movable M; @@ -141,7 +139,7 @@ L<int> l(Movable()); // Test with a non-instantiated template class. template <typename T> struct N { - N(Movable M) : M(std::move(M)) {} + N(const Movable &M) : M(M) {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move // CHECK-FIXES: N(Movable M) : M(std::move(M)) {} @@ -151,7 +149,7 @@ template <typename T> struct N { // Test with value parameter. struct O { - O(Movable M) : M(std::move(M)) {} + 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; @@ -167,8 +165,8 @@ struct P { // Test with multiples parameters where some need to be changed and some don't. // need to. struct Q { - Q(const Movable &A, Movable B, Movable C, double D) - : A(A), B(std::move(B)), C(std::move(C)), D(D) {} + Q(const Movable &A, const Movable &B, const Movable &C, double D) + : A(A), B(B), C(C), D(D) {} // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: pass by value and use std::move // CHECK-MESSAGES: :[[@LINE-3]]:41: warning: pass by value and use std::move // CHECK-FIXES: Q(const Movable &A, Movable B, Movable C, double D) @@ -184,7 +182,7 @@ namespace ns_R { typedef ::Movable RMovable; } struct R { - R(ns_R::RMovable M) : M(std::move(M)) {} + 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; |

