mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-07 11:56:51 +00:00
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:
parent
3c690350be
commit
88e7b97c2a
@ -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
|
||||
|
26
tools/clang-tidy/test/bugprone-move-forwarding-reference.cpp
Normal file
26
tools/clang-tidy/test/bugprone-move-forwarding-reference.cpp
Normal 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);
|
||||
}
|
||||
|
@ -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"}]
|
Loading…
Reference in New Issue
Block a user