Bug 1188204 - Fix more constructors in MFBT; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 27 Jul 2015 21:12:06 -0400
changeset 288304 02f08045a3bc004fcd2849fcaca05a220eee72c4
parent 288303 74f0c724abfc5ecfff2482098feb5d5986761f08
child 288305 fb278d03ce5a5b66db0198d1c099481998a31fb5
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1188204
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1188204 - Fix more constructors in MFBT; r=froydnj
mfbt/AlreadyAddRefed.h
mfbt/CheckedInt.h
mfbt/EnumeratedRange.h
mfbt/IntegerRange.h
mfbt/RangedPtr.h
mfbt/ReentrancyGuard.h
mfbt/RefPtr.h
mfbt/ReverseIterator.h
mfbt/UniquePtr.h
--- a/mfbt/AlreadyAddRefed.h
+++ b/mfbt/AlreadyAddRefed.h
@@ -91,17 +91,17 @@ struct MOZ_MUST_USE already_AddRefed
    * The autoconversion allows one to omit the idiom
    *
    *    nsRefPtr<BaseClass> y = x.forget();
    *    return y.forget();
    *
    * Note that nsRefPtr is the XPCOM reference counting smart pointer class.
    */
   template <typename U>
-  already_AddRefed(already_AddRefed<U>&& aOther) : mRawPtr(aOther.take()) {}
+  MOZ_IMPLICIT already_AddRefed(already_AddRefed<U>&& aOther) : mRawPtr(aOther.take()) {}
 
   ~already_AddRefed() { MOZ_ASSERT(!mRawPtr); }
 
   // Specialize the unused operator<< for already_AddRefed, to allow
   // nsCOMPtr<nsIFoo> foo;
   // unused << foo.forget();
   // Note that nsCOMPtr is the XPCOM reference counting smart pointer class.
   friend void operator<<(const mozilla::unused_t& aUnused,
--- a/mfbt/CheckedInt.h
+++ b/mfbt/CheckedInt.h
@@ -521,17 +521,17 @@ public:
    *
    * This constructor is not explicit. Instead, the type of its argument is a
    * separate template parameter, ensuring that no conversion is performed
    * before this constructor is actually called. As explained in the above
    * documentation for class CheckedInt, this constructor checks that its
    * argument is valid.
    */
   template<typename U>
-  CheckedInt(U aValue) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT
+  MOZ_IMPLICIT CheckedInt(U aValue) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT
     : mValue(T(aValue)),
       mIsValid(detail::IsInRange<T>(aValue))
   {
     static_assert(detail::IsSupported<T>::value &&
                   detail::IsSupported<U>::value,
                   "This type is not supported by CheckedInt");
   }
 
--- a/mfbt/EnumeratedRange.h
+++ b/mfbt/EnumeratedRange.h
@@ -31,17 +31,17 @@ template<typename IntTypeT, typename Enu
 class EnumeratedIterator
 {
 public:
   template<typename EnumType>
   explicit EnumeratedIterator(EnumType aCurrent)
     : mCurrent(aCurrent) { }
 
   template<typename IntType, typename EnumType>
-  EnumeratedIterator(const EnumeratedIterator<IntType, EnumType>& aOther)
+  explicit EnumeratedIterator(const EnumeratedIterator<IntType, EnumType>& aOther)
     : mCurrent(aOther.mCurrent) { }
 
   EnumTypeT operator*() const { return mCurrent; }
 
   /* Increment and decrement operators */
 
   EnumeratedIterator& operator++()
   {
--- a/mfbt/IntegerRange.h
+++ b/mfbt/IntegerRange.h
@@ -21,17 +21,17 @@ template<typename IntTypeT>
 class IntegerIterator
 {
 public:
   template<typename IntType>
   explicit IntegerIterator(IntType aCurrent)
     : mCurrent(aCurrent) { }
 
   template<typename IntType>
-  IntegerIterator(const IntegerIterator<IntType>& aOther)
+  explicit IntegerIterator(const IntegerIterator<IntType>& aOther)
     : mCurrent(aOther.mCurrent) { }
 
   IntTypeT operator*() const { return mCurrent; }
 
   /* Increment and decrement operators */
 
   IntegerIterator& operator++() { ++mCurrent; return *this; }
   IntegerIterator& operator--() { --mCurrent; return *this; }
--- a/mfbt/RangedPtr.h
+++ b/mfbt/RangedPtr.h
@@ -99,17 +99,17 @@ public:
     MOZ_ASSERT(aLength <= size_t(-1) / sizeof(T));
     MOZ_ASSERT(reinterpret_cast<uintptr_t>(mRangeStart) + aLength * sizeof(T) >=
                reinterpret_cast<uintptr_t>(mRangeStart));
     checkSanity();
   }
 
   /* Equivalent to RangedPtr(aArr, aArr, N). */
   template<size_t N>
-  RangedPtr(T (&aArr)[N])
+  explicit RangedPtr(T (&aArr)[N])
     : mPtr(aArr)
 #ifdef DEBUG
     , mRangeStart(aArr), mRangeEnd(aArr + N)
 #endif
   {
     checkSanity();
   }
 
--- a/mfbt/ReentrancyGuard.h
+++ b/mfbt/ReentrancyGuard.h
@@ -21,22 +21,22 @@ class ReentrancyGuard
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 #ifdef DEBUG
   bool& mEntered;
 #endif
 
 public:
   template<class T>
 #ifdef DEBUG
-  ReentrancyGuard(T& aObj
-                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+  explicit ReentrancyGuard(T& aObj
+                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mEntered(aObj.mEntered)
 #else
-  ReentrancyGuard(T&
-                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+  explicit ReentrancyGuard(T&
+                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
 #endif
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 #ifdef DEBUG
     MOZ_ASSERT(!mEntered);
     mEntered = true;
 #endif
   }
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -233,17 +233,17 @@ class RefPtr
 public:
   RefPtr() : mPtr(0) {}
   RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {}
   MOZ_IMPLICIT RefPtr(already_AddRefed<T>& aOther) : mPtr(aOther.take()) {}
   MOZ_IMPLICIT RefPtr(already_AddRefed<T>&& aOther) : mPtr(aOther.take()) {}
   MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {}
 
   template<typename U>
-  RefPtr(const RefPtr<U>& aOther) : mPtr(ref(aOther.get())) {}
+  MOZ_IMPLICIT RefPtr(const RefPtr<U>& aOther) : mPtr(ref(aOther.get())) {}
 
   ~RefPtr() { unref(mPtr); }
 
   RefPtr& operator=(const RefPtr& aOther)
   {
     assign(ref(aOther.mPtr));
     return *this;
   }
--- a/mfbt/ReverseIterator.h
+++ b/mfbt/ReverseIterator.h
@@ -121,21 +121,21 @@ class IteratorRange
 {
 public:
   typedef IteratorT iterator;
   typedef IteratorT const_iterator;
   typedef ReverseIterator<IteratorT> reverse_iterator;
   typedef ReverseIterator<IteratorT> const_reverse_iterator;
 
   template<typename Iterator1, typename Iterator2>
-  IteratorRange(Iterator1 aIterBegin, Iterator2 aIterEnd)
+  MOZ_IMPLICIT IteratorRange(Iterator1 aIterBegin, Iterator2 aIterEnd)
     : mIterBegin(aIterBegin), mIterEnd(aIterEnd) { }
 
   template<typename Iterator>
-  IteratorRange(const IteratorRange<Iterator>& aOther)
+  MOZ_IMPLICIT IteratorRange(const IteratorRange<Iterator>& aOther)
     : mIterBegin(aOther.mIterBegin), mIterEnd(aOther.mIterEnd) { }
 
   iterator begin() const { return mIterBegin; }
   const_iterator cbegin() const { return begin(); }
   iterator end() const { return mIterEnd; }
   const_iterator cend() const { return end(); }
   reverse_iterator rbegin() const { return reverse_iterator(mIterEnd); }
   const_reverse_iterator crbegin() const { return rbegin(); }
--- a/mfbt/UniquePtr.h
+++ b/mfbt/UniquePtr.h
@@ -233,16 +233,17 @@ public:
   UniquePtr(decltype(nullptr))
     : mTuple(nullptr, DeleterType())
   {
     static_assert(!IsPointer<D>::value, "must provide a deleter instance");
     static_assert(!IsReference<D>::value, "must provide a deleter instance");
   }
 
   template<typename U, class E>
+  MOZ_IMPLICIT
   UniquePtr(UniquePtr<U, E>&& aOther,
             typename EnableIf<IsConvertible<typename UniquePtr<U, E>::Pointer,
                                             Pointer>::value &&
                               !IsArray<U>::value &&
                               (IsReference<D>::value
                                ? IsSame<D, E>::value
                                : IsConvertible<E, D>::value),
                               int>::Type aDummy = 0)
@@ -473,19 +474,19 @@ private:
 /** A default deletion policy using plain old operator delete. */
 template<typename T>
 class DefaultDelete
 {
 public:
   MOZ_CONSTEXPR DefaultDelete() {}
 
   template<typename U>
-  DefaultDelete(const DefaultDelete<U>& aOther,
-                typename EnableIf<mozilla::IsConvertible<U*, T*>::value,
-                                  int>::Type aDummy = 0)
+  MOZ_IMPLICIT DefaultDelete(const DefaultDelete<U>& aOther,
+                             typename EnableIf<mozilla::IsConvertible<U*, T*>::value,
+                                               int>::Type aDummy = 0)
   {}
 
   void operator()(T* aPtr) const
   {
     static_assert(sizeof(T) > 0, "T must be complete");
     delete aPtr;
   }
 };