Backed out changeset 11aebde6e809 (bug 1120059) because of build bustage on Windows
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 13 Jan 2015 00:26:16 -0500
changeset 252257 5f146f3b136296380ea788d929758148a6925f34
parent 252256 6295dbaa06def52343564a3f9ac66fe519628117
child 252258 949eb015c431e5fa27608144c491a07b4362c98c
push id721
push userjlund@mozilla.com
push dateTue, 21 Apr 2015 23:03:33 +0000
treeherdermozilla-release@d27c9211ebb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1120059
milestone38.0a1
backs out11aebde6e809d32c6b37e23de66fe9e674f5490c
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
Backed out changeset 11aebde6e809 (bug 1120059) because of build bustage on Windows
gfx/layers/LayerMetricsWrapper.h
mfbt/Attributes.h
mfbt/TypedEnumInternal.h
mfbt/tests/TestTypedEnum.cpp
widget/BasicEvents.h
--- a/gfx/layers/LayerMetricsWrapper.h
+++ b/gfx/layers/LayerMetricsWrapper.h
@@ -163,17 +163,17 @@ public:
     MOZ_ASSERT(mIndex == 0 || mIndex < mLayer->GetFrameMetricsCount());
   }
 
   bool IsValid() const
   {
     return mLayer != nullptr;
   }
 
-  explicit operator bool() const
+  MOZ_EXPLICIT_CONVERSION operator bool() const
   {
     return IsValid();
   }
 
   bool IsScrollInfoLayer() const
   {
     MOZ_ASSERT(IsValid());
 
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -50,33 +50,39 @@
  * don't indicate support for them here, due to
  * http://stackoverflow.com/questions/20498142/visual-studio-2013-explicit-keyword-bug
  */
 #  define MOZ_HAVE_CXX11_FINAL         final
 #  define MOZ_HAVE_CXX11_OVERRIDE
 #  define MOZ_HAVE_NEVER_INLINE          __declspec(noinline)
 #  define MOZ_HAVE_NORETURN              __declspec(noreturn)
 #  ifdef __clang__
-     /* clang-cl probably supports constexpr. */
+     /* clang-cl probably supports constexpr and explicit conversions. */
 #    if __has_extension(cxx_constexpr)
 #      define MOZ_HAVE_CXX11_CONSTEXPR
 #    endif
+#    if __has_extension(cxx_explicit_conversions)
+#      define MOZ_HAVE_EXPLICIT_CONVERSION
+#    endif
 #  endif
 #elif defined(__clang__)
    /*
     * Per Clang documentation, "Note that marketing version numbers should not
     * be used to check for language features, as different vendors use different
     * numbering schemes. Instead, use the feature checking macros."
     */
 #  ifndef __has_extension
 #    define __has_extension __has_feature /* compatibility, for older versions of clang */
 #  endif
 #  if __has_extension(cxx_constexpr)
 #    define MOZ_HAVE_CXX11_CONSTEXPR
 #  endif
+#  if __has_extension(cxx_explicit_conversions)
+#    define MOZ_HAVE_EXPLICIT_CONVERSION
+#  endif
 #  if __has_extension(cxx_override_control)
 #    define MOZ_HAVE_CXX11_OVERRIDE
 #    define MOZ_HAVE_CXX11_FINAL         final
 #  endif
 #  if __has_attribute(noinline)
 #    define MOZ_HAVE_NEVER_INLINE        __attribute__((noinline))
 #  endif
 #  if __has_attribute(noreturn)
@@ -86,16 +92,19 @@
 #  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
 #    if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
 #      define MOZ_HAVE_CXX11_OVERRIDE
 #      define MOZ_HAVE_CXX11_FINAL       final
 #    endif
 #    if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
 #      define MOZ_HAVE_CXX11_CONSTEXPR
 #    endif
+#    if MOZ_GCC_VERSION_AT_LEAST(4, 5, 0)
+#      define MOZ_HAVE_EXPLICIT_CONVERSION
+#    endif
 #  else
      /* __final is a non-C++11 GCC synonym for 'final', per GCC r176655. */
 #    if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
 #      define MOZ_HAVE_CXX11_FINAL       __final
 #    endif
 #  endif
 #  define MOZ_HAVE_NEVER_INLINE          __attribute__((noinline))
 #  define MOZ_HAVE_NORETURN              __attribute__((noreturn))
@@ -125,16 +134,41 @@
 #  define MOZ_CONSTEXPR         constexpr
 #  define MOZ_CONSTEXPR_VAR     constexpr
 #else
 #  define MOZ_CONSTEXPR         /* no support */
 #  define MOZ_CONSTEXPR_VAR     const
 #endif
 
 /*
+ * MOZ_EXPLICIT_CONVERSION is a specifier on a type conversion
+ * overloaded operator that declares that a C++11 compiler should restrict
+ * this operator to allow only explicit type conversions, disallowing
+ * implicit conversions.
+ *
+ * Example:
+ *
+ *   template<typename T>
+ *   class Ptr
+ *   {
+ *     T* mPtr;
+ *     MOZ_EXPLICIT_CONVERSION operator bool() const
+ *     {
+ *       return mPtr != nullptr;
+ *     }
+ *   };
+ *
+ */
+#ifdef MOZ_HAVE_EXPLICIT_CONVERSION
+#  define MOZ_EXPLICIT_CONVERSION explicit
+#else
+#  define MOZ_EXPLICIT_CONVERSION /* no support */
+#endif
+
+/*
  * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
  * method decorated with it must never be inlined, even if the compiler would
  * otherwise choose to inline the method.  Compilers aren't absolutely
  * guaranteed to support this, but most do.
  */
 #if defined(MOZ_HAVE_NEVER_INLINE)
 #  define MOZ_NEVER_INLINE      MOZ_HAVE_NEVER_INLINE
 #else
--- a/mfbt/TypedEnumInternal.h
+++ b/mfbt/TypedEnumInternal.h
@@ -76,17 +76,17 @@ private:
 public:
   explicit MOZ_CONSTEXPR CastableTypedEnumResult(E aValue)
     : mValue(aValue)
   {}
 
   MOZ_CONSTEXPR operator E() const { return mValue; }
 
   template<typename DestinationType>
-  explicit MOZ_CONSTEXPR
+  MOZ_EXPLICIT_CONVERSION MOZ_CONSTEXPR
   operator DestinationType() const { return DestinationType(mValue); }
 
   MOZ_CONSTEXPR bool operator !() const { return !bool(mValue); }
 
 #ifndef MOZ_HAVE_CXX11_STRONG_ENUMS
   // This get() method is used to implement a constructor in the
   // non-c++11 fallback path for MOZ_BEGIN_ENUM_CLASS, taking a
   // CastableTypedEnumResult. If we try to implement it using the
--- a/mfbt/tests/TestTypedEnum.cpp
+++ b/mfbt/tests/TestTypedEnum.cpp
@@ -155,17 +155,17 @@ MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned
 #undef MAKE_STANDARD_BITFIELD_FOR_TYPE
 
 template<typename T>
 void
 TestNonConvertibilityForOneType()
 {
   using mozilla::IsConvertible;
 
-#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS)
+#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) && defined(MOZ_HAVE_EXPLICIT_CONVERSION)
   static_assert(!IsConvertible<T, bool>::value, "should not be convertible");
   static_assert(!IsConvertible<T, int>::value, "should not be convertible");
   static_assert(!IsConvertible<T, uint64_t>::value, "should not be convertible");
 #endif
 
   static_assert(!IsConvertible<bool, T>::value, "should not be convertible");
   static_assert(!IsConvertible<int, T>::value, "should not be convertible");
   static_assert(!IsConvertible<uint64_t, T>::value, "should not be convertible");
@@ -430,22 +430,28 @@ void TestNoConversionsBetweenUnrelatedTy
 
   static_assert(!IsConvertible<decltype(T1::A), T2>::value,
                 "should not be convertible");
   static_assert(!IsConvertible<decltype(T1::A), decltype(T2::A)>::value,
                 "should not be convertible");
   static_assert(!IsConvertible<decltype(T1::A), decltype(T2::A | T2::B)>::value,
                 "should not be convertible");
 
+  // The following are #ifdef MOZ_HAVE_EXPLICIT_CONVERSION because without
+  // support for explicit conversion operators, we can't easily have these bad
+  // conversions completely removed. They still do fail to compile in practice,
+  // but not in a way that we can static_assert on.
+#ifdef MOZ_HAVE_EXPLICIT_CONVERSION
   static_assert(!IsConvertible<decltype(T1::A | T1::B), T2>::value,
                 "should not be convertible");
   static_assert(!IsConvertible<decltype(T1::A | T1::B), decltype(T2::A)>::value,
                 "should not be convertible");
   static_assert(!IsConvertible<decltype(T1::A | T1::B), decltype(T2::A | T2::B)>::value,
                 "should not be convertible");
+#endif
 }
 
 MOZ_BEGIN_ENUM_CLASS(Int8EnumWithHighBits, int8_t)
   A = 0x20,
   B = 0x40
 MOZ_END_ENUM_CLASS(Int8EnumWithHighBits)
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int8EnumWithHighBits)
 
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -873,23 +873,23 @@ public:
   class PluginEvent MOZ_FINAL
   {
     nsTArray<uint8_t> mBuffer;
 
     friend struct IPC::ParamTraits<mozilla::WidgetGUIEvent>;
 
   public:
 
-    explicit operator bool() const
+    MOZ_EXPLICIT_CONVERSION operator bool() const
     {
       return !mBuffer.IsEmpty();
     }
 
     template<typename T>
-    explicit operator const T*() const
+    MOZ_EXPLICIT_CONVERSION operator const T*() const
     {
       return mBuffer.IsEmpty()
              ? nullptr
              : reinterpret_cast<const T*>(mBuffer.Elements());
     }
 
     template <typename T>
     void Copy(const T& other)