Bug 1120059 - Remove MOZ_{HAVE_,}EXPLICIT_CONVERSION. r=Waldo

This commit is contained in:
Birunthan Mohanathas 2015-01-13 06:41:15 +02:00
parent 60aff802ee
commit 8a228c8946
5 changed files with 6 additions and 46 deletions

View File

@ -168,7 +168,7 @@ public:
return mLayer != nullptr;
}
MOZ_EXPLICIT_CONVERSION operator bool() const
explicit operator bool() const
{
return IsValid();
}

View File

@ -55,13 +55,10 @@
# define MOZ_HAVE_NEVER_INLINE __declspec(noinline)
# define MOZ_HAVE_NORETURN __declspec(noreturn)
# ifdef __clang__
/* clang-cl probably supports constexpr and explicit conversions. */
/* clang-cl probably supports constexpr. */
# 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__)
/*
@ -75,9 +72,6 @@
# 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
@ -97,9 +91,6 @@
# 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)
@ -138,31 +129,6 @@
# 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

View File

@ -81,7 +81,7 @@ public:
MOZ_CONSTEXPR operator E() const { return mValue; }
template<typename DestinationType>
MOZ_EXPLICIT_CONVERSION MOZ_CONSTEXPR
explicit MOZ_CONSTEXPR
operator DestinationType() const { return DestinationType(mValue); }
MOZ_CONSTEXPR bool operator !() const { return !bool(mValue); }

View File

@ -160,7 +160,7 @@ TestNonConvertibilityForOneType()
{
using mozilla::IsConvertible;
#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) && defined(MOZ_HAVE_EXPLICIT_CONVERSION)
#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS)
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");
@ -435,18 +435,12 @@ void TestNoConversionsBetweenUnrelatedTypes()
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)

View File

@ -878,13 +878,13 @@ public:
public:
MOZ_EXPLICIT_CONVERSION operator bool() const
explicit operator bool() const
{
return !mBuffer.IsEmpty();
}
template<typename T>
MOZ_EXPLICIT_CONVERSION operator const T*() const
explicit operator const T*() const
{
return mBuffer.IsEmpty()
? nullptr