Bug 1551083 - Enable bugprone-move-forwarding-reference r=andi

Differential Revision: https://phabricator.services.mozilla.com/D30816

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Sylvestre Ledru 2019-05-14 07:12:37 +00:00
parent 3c690350be
commit 88e7b97c2a
3 changed files with 29 additions and 0 deletions

View File

@ -40,6 +40,8 @@ clang_checkers:
reliability: high
- name: bugprone-misplaced-widening-cast
reliability: high
- name: bugprone-move-forwarding-reference
reliability: high
- name: bugprone-multiple-statement-macro
# Incompatible with our code base, see bug 1496379.
publish: !!bool no

View File

@ -0,0 +1,26 @@
namespace std {
template <typename> struct remove_reference;
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);
} // namespace std
// Standard case.
template <typename T, typename U> void f1(U &&SomeU) {
T SomeT(std::move(SomeU));
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
// CHECK-FIXES: T SomeT(std::forward<U>(SomeU));
}
void foo() {
f1<int, int>(2);
}

View File

@ -0,0 +1 @@
[["warning", "forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead", "bugprone-move-forwarding-reference"], {"reliability": "high"}]