Author: madsravn Date: Tue May 24 10:13:44 2016 New Revision: 270567 URL: http://llvm.org/viewvc/llvm-project?rev=270567&view=rev Log: [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 Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=270567&r1=270566&r2=270567&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Tue May 24 10:13:44 2016 @@ -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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits