Author: shuaiwang Date: Mon Sep 17 14:28:08 2018 New Revision: 342417 URL: http://llvm.org/viewvc/llvm-project?rev=342417&view=rev Log: [clang-tidy] Fix tests for performance-for-range-copy
Test failed as D52120 made ExprMutationAnalyzer smarter, fixed by: - Add move-ctor for `Mutable` to make it actually movable. - Properly implement `remove_reference`. The failed test case is: void negativeVarIsMoved() { for (auto M : View<Iterator<Mutable>>()) { auto Moved = std::move(M); } } Before D52120, `std::move(M)` itself is considered as a mutation to `M`, while after D52120 it's only considered as a cast to rvalue, the move-assignment is what causes the actual mutation. The test case didn't mock things properly so the intended move-assignement was actually a copy-assignment. Modified: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp?rev=342417&r1=342416&r2=342417&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp Mon Sep 17 14:28:08 2018 @@ -4,6 +4,10 @@ namespace std { template <typename _Tp> struct remove_reference { typedef _Tp type; }; +template <typename _Tp> +struct remove_reference<_Tp&> { typedef _Tp type; }; +template <typename _Tp> +struct remove_reference<_Tp&&> { typedef _Tp type; }; template <typename _Tp> constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) { @@ -103,6 +107,7 @@ void f() { struct Mutable { Mutable() {} Mutable(const Mutable &) = default; + Mutable(Mutable&&) = default; Mutable(const Mutable &, const Mutable &) {} void setBool(bool B) {} bool constMethod() const { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits