Bug 1048013 - Fix some bad implicit constructors in MFBT; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 05 Aug 2014 09:21:12 -0400
changeset 197937 2dbeb8d5eeec4b6a1502036ed798c576fafb7528
parent 197936 1dfc15b582d162895a045199f8ac6a68c626325e
child 197938 0f10ded995a781358e0ee20b32c4e55cc4803c6e
push id27256
push userkwierso@gmail.com
push dateWed, 06 Aug 2014 00:06:20 +0000
treeherdermozilla-central@6cbdd4d523a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1048013
milestone34.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 1048013 - Fix some bad implicit constructors in MFBT; r=froydnj
mfbt/WeakPtr.h
mfbt/tests/TestPair.cpp
mfbt/tests/TestSplayTree.cpp
--- a/mfbt/WeakPtr.h
+++ b/mfbt/WeakPtr.h
@@ -178,17 +178,17 @@ public:
     *this = aOther;
   }
 
   WeakPtr& operator=(T* aOther)
   {
     return *this = aOther->SelfReferencingWeakPtr();
   }
 
-  WeakPtr(T* aOther)
+  MOZ_IMPLICIT WeakPtr(T* aOther)
   {
     *this = aOther;
   }
 
   // Ensure that mRef is dereferenceable in the uninitialized state.
   WeakPtr() : mRef(new WeakReference(nullptr)) {}
 
   operator T*() const { return mRef->get(); }
--- a/mfbt/tests/TestPair.cpp
+++ b/mfbt/tests/TestPair.cpp
@@ -24,31 +24,31 @@ using mozilla::Pair;
   static_assert(sizeof(name##_2.second()) > 0, \
                 "second method should work on Pair<" #T2 ", " #T1 ">"); \
   static_assert(sizeof(name##_2) == (size), \
                 "Pair<" #T2 ", " #T1 "> has an unexpected size");
 
 INSTANTIATE(int, int, prim1, 2 * sizeof(int));
 INSTANTIATE(int, long, prim2, 2 * sizeof(long));
 
-struct EmptyClass { EmptyClass(int) {} };
-struct NonEmpty { char mC; NonEmpty(int) {} };
+struct EmptyClass { explicit EmptyClass(int) {} };
+struct NonEmpty { char mC; explicit NonEmpty(int) {} };
 
 INSTANTIATE(int, EmptyClass, both1, sizeof(int));
 INSTANTIATE(int, NonEmpty, both2, 2 * sizeof(int));
 INSTANTIATE(EmptyClass, NonEmpty, both3, 1);
 
-struct A { char dummy; A(int) {} };
-struct B : A { B(int aI) : A(aI) {} };
+struct A { char dummy; explicit A(int) {} };
+struct B : A { explicit B(int aI) : A(aI) {} };
 
 INSTANTIATE(A, A, class1, 2);
 INSTANTIATE(A, B, class2, 2);
 INSTANTIATE(A, EmptyClass, class3, 1);
 
-struct OtherEmpty : EmptyClass { OtherEmpty(int aI) : EmptyClass(aI) {} };
+struct OtherEmpty : EmptyClass { explicit OtherEmpty(int aI) : EmptyClass(aI) {} };
 
 // C++11 requires distinct objects of the same type, within the same "most
 // derived object", to have different addresses.  Pair allocates its elements as
 // two bases, a base and a member, or two members.  If the two elements have
 // non-zero size or are unrelated, no big deal.  But if they're both empty and
 // related, something -- possibly both -- must be inflated.  Exactly which are
 // inflated depends which PairHelper specialization is used.  We could
 // potentially assert something about size for this case, but whatever we could
--- a/mfbt/tests/TestSplayTree.cpp
+++ b/mfbt/tests/TestSplayTree.cpp
@@ -84,17 +84,17 @@ static int gValues[] = {
   115, 988, 978, 762, 486, 301, 616, 10, 78, 603, 452, 965, 279, 972, 413, 895,
   591, 662, 594, 348, 423, 489, 43, 699, 433, 509, 355, 270, 66, 83, 95, 561,
   661, 562, 329, 620, 370, 64, 187, 503, 716, 856, 310, 786, 167, 71, 239, 359,
   537, 437, 305, 673, 824, 911, 681, 271
 };
 
 struct SplayInt : SplayTreeNode<SplayInt>
 {
-  SplayInt(int aValue) : mValue(aValue) {}
+  explicit SplayInt(int aValue) : mValue(aValue) {}
 
   static int compare(const SplayInt& aOne, const SplayInt& aTwo)
   {
     if (aOne.mValue < aTwo.mValue) {
       return -1;
     }
     if (aOne.mValue > aTwo.mValue) {
       return 1;