Bug 1397344 - Use Decay to ensure StoreCopyPassByXXX stores the value by copy not by reference. r=gerald
authorJames Cheng <jacheng@mozilla.com>
Thu, 07 Sep 2017 17:02:13 +0800
changeset 662267 5b3b0c446caa3cb7f23c072487d6353561c25d2c
parent 662266 005cddf9e02038e5fd6c5e1590f6795df6648fe9
child 662268 38e3ac4eee425ead861938e5406466ba585cc48b
push id79014
push userbmo:bpostelnicu@mozilla.com
push dateMon, 11 Sep 2017 09:58:20 +0000
reviewersgerald
bugs1397344
milestone57.0a1
Bug 1397344 - Use Decay to ensure StoreCopyPassByXXX stores the value by copy not by reference. r=gerald MozReview-Commit-ID: Ec9yjYdQ1jC
xpcom/threads/nsThreadUtils.h
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -837,60 +837,60 @@ template<typename T>
 struct IsParameterStorageClass : public mozilla::FalseType {};
 
 // StoreXPassByY structs used to inform nsRunnableMethodArguments how to
 // store arguments, and how to pass them to the target method.
 
 template<typename T>
 struct StoreCopyPassByValue
 {
-  typedef T stored_type;
-  typedef T passed_type;
+  typedef typename mozilla::Decay<T>::Type stored_type;
+  typedef stored_type passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByValue(A&& a) : m(mozilla::Forward<A>(a)) {}
   passed_type PassAsParameter() { return m; }
 };
 template<typename S>
 struct IsParameterStorageClass<StoreCopyPassByValue<S>>
   : public mozilla::TrueType {};
 
 template<typename T>
 struct StoreCopyPassByConstLRef
 {
-  typedef T stored_type;
-  typedef const T& passed_type;
+  typedef typename mozilla::Decay<T>::Type stored_type;
+  typedef const stored_type& passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByConstLRef(A&& a) : m(mozilla::Forward<A>(a)) {}
   passed_type PassAsParameter() { return m; }
 };
 template<typename S>
 struct IsParameterStorageClass<StoreCopyPassByConstLRef<S>>
   : public mozilla::TrueType {};
 
 template<typename T>
 struct StoreCopyPassByLRef
 {
-  typedef T stored_type;
-  typedef T& passed_type;
+  typedef typename mozilla::Decay<T>::Type stored_type;
+  typedef stored_type& passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByLRef(A&& a) : m(mozilla::Forward<A>(a)) {}
   passed_type PassAsParameter() { return m; }
 };
 template<typename S>
 struct IsParameterStorageClass<StoreCopyPassByLRef<S>>
   : public mozilla::TrueType {};
 
 template<typename T>
 struct StoreCopyPassByRRef
 {
-  typedef T stored_type;
-  typedef T&& passed_type;
+  typedef typename mozilla::Decay<T>::Type stored_type;
+  typedef stored_type&& passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByRRef(A&& a) : m(mozilla::Forward<A>(a)) {}
   passed_type PassAsParameter() { return mozilla::Move(m); }
 };
 template<typename S>
 struct IsParameterStorageClass<StoreCopyPassByRRef<S>>
   : public mozilla::TrueType {};