Skip to content

Commit 07873f2

Browse files
Add test
1 parent 648995c commit 07873f2

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
2+
// RUN: -config="{CheckOptions: {cppcoreguidelines-rvalue-reference-param-not-moved.AllowPartialMove: true, cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams: true, cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes: true, cppcoreguidelines-rvalue-reference-param-not-moved.MoveFunction: custom_move}}" -- -fno-delayed-template-parsing
3+
4+
// NOLINTBEGIN
5+
namespace std {
6+
template <typename>
7+
struct remove_reference;
8+
9+
template <typename _Tp> struct remove_reference { typedef _Tp type; };
10+
template <typename _Tp> struct remove_reference<_Tp&> { typedef _Tp type; };
11+
template <typename _Tp> struct remove_reference<_Tp&&> { typedef _Tp type; };
12+
13+
template <typename _Tp>
14+
constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
15+
16+
template <typename _Tp>
17+
constexpr _Tp &&
18+
forward(typename remove_reference<_Tp>::type &__t) noexcept;
19+
20+
}
21+
// NOLINTEND
22+
23+
24+
struct Obj {
25+
Obj();
26+
Obj(const Obj&);
27+
Obj& operator=(const Obj&);
28+
Obj(Obj&&);
29+
Obj& operator=(Obj&&);
30+
void member() const;
31+
};
32+
33+
template<class T>
34+
constexpr typename std::remove_reference<T>::type&& custom_move(T&& x) noexcept
35+
{
36+
return static_cast<typename std::remove_reference<T>::type&&>(x);
37+
}
38+
39+
void move_with_std(Obj&& o) {
40+
// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
41+
Obj other{std::move(o)};
42+
}
43+
44+
void move_with_custom(Obj&& o) {
45+
Obj other{custom_move(o)};
46+
}
47+

0 commit comments

Comments
 (0)