[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.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342417 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/clang-tidy/performance-for-range-copy.cpp b/test/clang-tidy/performance-for-range-copy.cpp
index 8a43ac0..5e174fa 100644
--- a/test/clang-tidy/performance-for-range-copy.cpp
+++ b/test/clang-tidy/performance-for-range-copy.cpp
@@ -4,6 +4,10 @@
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 @@
struct Mutable {
Mutable() {}
Mutable(const Mutable &) = default;
+ Mutable(Mutable&&) = default;
Mutable(const Mutable &, const Mutable &) {}
void setBool(bool B) {}
bool constMethod() const {