brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 4ed2982 Raw
48 lines · cpp
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-parsing3 4// NOLINTBEGIN5namespace std {6template <typename>7struct remove_reference;8 9template <typename _Tp> struct remove_reference { typedef _Tp type; };10template <typename _Tp> struct remove_reference<_Tp&> { typedef _Tp type; };11template <typename _Tp> struct remove_reference<_Tp&&> { typedef _Tp type; };12 13template <typename _Tp>14constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;15 16template <typename _Tp>17constexpr _Tp &&18forward(typename remove_reference<_Tp>::type &__t) noexcept;19 20}21// NOLINTEND22 23 24struct 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 33template<class T>34constexpr typename std::remove_reference<T>::type&& custom_move(T&& x) noexcept35{36    return static_cast<typename std::remove_reference<T>::type&&>(x);37}38 39void 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 44void move_with_custom(Obj&& o) {45  Obj other{custom_move(o)};46}47 48