Bug 1481097 - xpcom: Remove nsTString literal string workaround for gcc 4.9 bug. r?nika draft
authorChris Peterson <cpeterson@mozilla.com>
Sun, 22 Jul 2018 00:02:34 -0700
changeset 826875 c3fbec637c33c99acb20b3f22507298df49c259e
parent 826874 8dd23750589f0e38fcadf60b214c5778d7743a97
push id118400
push usercpeterson@mozilla.com
push dateSun, 05 Aug 2018 22:56:09 +0000
reviewersnika
bugs1481097, 1377351, 1444274
milestone63.0a1
Bug 1481097 - xpcom: Remove nsTString literal string workaround for gcc 4.9 bug. r?nika This gcc 4.9 workaround (from bug 1377351) is no longer needed because Firefox currently requires gcc 6.1 or later (as of bug 1444274). MozReview-Commit-ID: 9R14BDzWEoj
xpcom/string/nsTString.h
xpcom/string/nsTStringRepr.h
xpcom/string/nsTSubstring.cpp
xpcom/string/nsTSubstring.h
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -33,18 +33,16 @@ public:
   // bindgen w/ clang 3.9 at least chokes on a typedef, but using is okay.
   using typename nsTSubstring<T>::substring_type;
 #else
   // On the other hand msvc chokes on the using statement. It seems others
   // don't care either way so we lump them in here.
   typedef typename nsTSubstring<T>::substring_type substring_type;
 #endif
 
-  typedef typename substring_type::literalstring_type literalstring_type;
-
   typedef typename substring_type::fallible_t fallible_t;
 
   typedef typename substring_type::char_type char_type;
   typedef typename substring_type::char_traits char_traits;
   typedef typename substring_type::incompatible_char_type incompatible_char_type;
 
   typedef typename substring_type::substring_tuple_type substring_tuple_type;
 
@@ -118,25 +116,16 @@ public:
 
   explicit
   nsTString(substring_type&& aReadable)
     : substring_type(ClassFlags::NULL_TERMINATED)
   {
     this->Assign(std::move(aReadable));
   }
 
-  // NOTE(nika): gcc 4.9 workaround. Remove when support is dropped.
-  explicit
-  nsTString(const literalstring_type& aReadable)
-    : substring_type(ClassFlags::NULL_TERMINATED)
-  {
-    this->Assign(aReadable);
-  }
-
-
   // |operator=| does not inherit, so we must define our own
   self_type& operator=(char_type aChar)
   {
     this->Assign(aChar);
     return *this;
   }
   self_type& operator=(const char_type* aData)
   {
@@ -166,22 +155,16 @@ public:
     this->Assign(aStr);
     return *this;
   }
   self_type& operator=(substring_type&& aStr)
   {
     this->Assign(std::move(aStr));
     return *this;
   }
-  // NOTE(nika): gcc 4.9 workaround. Remove when support is dropped.
-  self_type& operator=(const literalstring_type& aStr)
-  {
-    this->Assign(aStr);
-    return *this;
-  }
   self_type& operator=(const substring_tuple_type& aTuple)
   {
     this->Assign(aTuple);
     return *this;
   }
 
   /**
    * returns the null-terminated string
@@ -565,17 +548,16 @@ public:
 
   typedef nsTString<T> base_string_type;
   typedef typename base_string_type::string_type string_type;
   typedef typename base_string_type::char_type char_type;
   typedef typename base_string_type::char_traits char_traits;
   typedef typename base_string_type::substring_type substring_type;
   typedef typename base_string_type::size_type size_type;
   typedef typename base_string_type::substring_tuple_type substring_tuple_type;
-  typedef typename base_string_type::literalstring_type literalstring_type;
 
   // These are only for internal use within the string classes:
   typedef typename base_string_type::DataFlags DataFlags;
   typedef typename base_string_type::ClassFlags ClassFlags;
 
 public:
 
   /**
@@ -635,24 +617,16 @@ public:
 
   explicit
   nsTAutoStringN(substring_type&& aStr)
     : self_type()
   {
     this->Assign(std::move(aStr));
   }
 
-  // NOTE(nika): gcc 4.9 workaround. Remove when support is dropped.
-  explicit
-  nsTAutoStringN(const literalstring_type& aStr)
-    : self_type()
-  {
-    this->Assign(aStr);
-  }
-
   MOZ_IMPLICIT nsTAutoStringN(const substring_tuple_type& aTuple)
     : self_type()
   {
     this->Assign(aTuple);
   }
 
   // |operator=| does not inherit, so we must define our own
   self_type& operator=(char_type aChar)
@@ -688,22 +662,16 @@ public:
     this->Assign(aStr);
     return *this;
   }
   self_type& operator=(substring_type&& aStr)
   {
     this->Assign(std::move(aStr));
     return *this;
   }
-  // NOTE(nika): gcc 4.9 workaround. Remove when support is dropped.
-  self_type& operator=(const literalstring_type& aStr)
-  {
-    this->Assign(aStr);
-    return *this;
-  }
   self_type& operator=(const substring_tuple_type& aTuple)
   {
     this->Assign(aTuple);
     return *this;
   }
 
   static const size_t kStorageSize = N;
 
--- a/xpcom/string/nsTStringRepr.h
+++ b/xpcom/string/nsTStringRepr.h
@@ -10,17 +10,16 @@
 #include <type_traits> // std::enable_if
 
 #include "mozilla/Char16.h"
 #include "mozilla/fallible.h"
 #include "nsStringFlags.h"
 #include "nsCharTraits.h"
 
 template <typename T> class nsTSubstringTuple;
-template <typename T> class nsTLiteralString;
 
 // The base for string comparators
 template <typename T> class nsTStringComparator
 {
 public:
   typedef T char_type;
 
   nsTStringComparator() {}
@@ -102,17 +101,16 @@ public:
   typedef nsCharTraits<char_type> char_traits;
   typedef typename char_traits::incompatible_char_type incompatible_char_type;
 
   typedef nsTStringRepr<T> self_type;
   typedef self_type base_string_type;
 
   typedef nsTSubstring<T> substring_type;
   typedef nsTSubstringTuple<T> substring_tuple_type;
-  typedef nsTLiteralString<T> literalstring_type;
 
   typedef nsReadingIterator<char_type> const_iterator;
   typedef nsWritingIterator<char_type> iterator;
 
   typedef nsTStringComparator<char_type> comparator_type;
 
   typedef char_type* char_iterator;
   typedef const char_type* const_char_iterator;
--- a/xpcom/string/nsTSubstring.cpp
+++ b/xpcom/string/nsTSubstring.cpp
@@ -527,24 +527,16 @@ nsTSubstring<T>::Assign(self_type&& aStr
   // We don't truncate the source string if the allocation failed.
   if (!Assign(aStr, aFallible)) {
     return false;
   }
   aStr.Truncate();
   return true;
 }
 
-// NOTE(nika): gcc 4.9 workaround. Remove when support is dropped.
-template <typename T>
-void
-nsTSubstring<T>::Assign(const literalstring_type& aStr)
-{
-  Assign(aStr.AsString());
-}
-
 template <typename T>
 void
 nsTSubstring<T>::Assign(const substring_tuple_type& aTuple)
 {
   if (!Assign(aTuple, mozilla::fallible)) {
     AllocFailed(aTuple.Length());
   }
 }
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -41,17 +41,16 @@ class nsTSubstring : public mozilla::det
 {
 public:
   typedef nsTSubstring<T> self_type;
 
   typedef nsTString<T> string_type;
 
   typedef typename mozilla::detail::nsTStringRepr<T> base_string_type;
   typedef typename base_string_type::substring_type substring_type;
-  typedef typename base_string_type::literalstring_type literalstring_type;
 
   typedef typename base_string_type::fallible_t fallible_t;
 
   typedef typename base_string_type::char_type char_type;
   typedef typename base_string_type::char_traits char_traits;
   typedef typename base_string_type::incompatible_char_type incompatible_char_type;
 
   typedef typename base_string_type::substring_tuple_type substring_tuple_type;
@@ -183,23 +182,16 @@ public:
                                        size_type aLength, const fallible_t&);
 
   void NS_FASTCALL Assign(const self_type&);
   MOZ_MUST_USE bool NS_FASTCALL Assign(const self_type&, const fallible_t&);
 
   void NS_FASTCALL Assign(self_type&&);
   MOZ_MUST_USE bool NS_FASTCALL Assign(self_type&&, const fallible_t&);
 
-  // XXX(nika): GCC 4.9 doesn't correctly resolve calls to Assign a
-  // nsLiteralCString into a nsTSubstring, due to a frontend bug. This explcit
-  // Assign overload (and the corresponding constructor and operator= overloads)
-  // are used to avoid this bug. Once we stop supporting GCC 4.9 we can remove
-  // them.
-  void NS_FASTCALL Assign(const literalstring_type&);
-
   void NS_FASTCALL Assign(const substring_tuple_type&);
   MOZ_MUST_USE bool NS_FASTCALL Assign(const substring_tuple_type&,
                                        const fallible_t&);
 
 #if defined(MOZ_USE_CHAR16_WRAPPER)
   template <typename Q = T, typename EnableIfChar16 = mozilla::Char16OnlyT<Q>>
   void Assign(char16ptr_t aData)
   {
@@ -279,22 +271,16 @@ public:
     Assign(aStr);
     return *this;
   }
   self_type& operator=(self_type&& aStr)
   {
     Assign(std::move(aStr));
     return *this;
   }
-  // NOTE(nika): gcc 4.9 workaround. Remove when support is dropped.
-  self_type& operator=(const literalstring_type& aStr)
-  {
-    Assign(aStr);
-    return *this;
-  }
   self_type& operator=(const substring_tuple_type& aTuple)
   {
     Assign(aTuple);
     return *this;
   }
 
   // Adopt a heap-allocated char sequence for this string; is Voided if aData
   // is null. Useful for e.g. converting an strdup'd C string into an