Bug 1478587 - Add CharT casts when comparing code units to particular ASCII characters. r=arai
☠☠ backed out by fd12c0a357b3 ☠ ☠
authorJeff Walden <jwalden@mit.edu>
Wed, 25 Jul 2018 20:11:12 -0700
changeset 823960 756cbd89533afb92baffa098676656c01b28761a
parent 823959 9546bfc93c7af1391bbcf901ed1ddc1304da8b80
child 823961 3a111fdc418dc36085b4d1a9a8a5526fedf7c5b3
push id117837
push userbmo:aryx.bugmail@gmx-topmail.de
push dateMon, 30 Jul 2018 09:42:15 +0000
reviewersarai
bugs1478587
milestone63.0a1
Bug 1478587 - Add CharT casts when comparing code units to particular ASCII characters. r=arai
js/src/frontend/TokenStream.cpp
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -1489,48 +1489,48 @@ TokenStreamSpecific<CharT, AnyCharsAcces
 // We have encountered a '\': check for a Unicode escape sequence after it.
 // Return the length of the escape sequence and the encoded code point (by
 // value) if we found a Unicode escape sequence, and skip all code units
 // involed.  Otherwise, return 0 and don't advance along the buffer.
 template<typename CharT, class AnyCharsAccess>
 uint32_t
 GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchUnicodeEscape(uint32_t* codePoint)
 {
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
 
     int32_t unit = getCodeUnit();
     if (unit != 'u') {
         // NOTE: |unit| may be EOF here.
         ungetCodeUnit(unit);
-        MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
+        MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
         return 0;
     }
 
     char16_t v;
     unit = getCodeUnit();
     if (JS7_ISHEX(unit) && this->sourceUnits.matchHexDigits(3, &v)) {
         *codePoint = (JS7_UNHEX(unit) << 12) | v;
         return 5;
     }
 
     if (unit == '{')
         return matchExtendedUnicodeEscape(codePoint);
 
     // NOTE: |unit| may be EOF here, so this ungets either one or two units.
     ungetCodeUnit(unit);
     ungetCodeUnit('u');
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
     return 0;
 }
 
 template<typename CharT, class AnyCharsAccess>
 uint32_t
 GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchExtendedUnicodeEscape(uint32_t* codePoint)
 {
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '{');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('{'));
 
     int32_t unit = getCodeUnit();
 
     // Skip leading zeroes.
     uint32_t leadingZeroes = 0;
     while (unit == '0') {
         leadingZeroes++;
         unit = getCodeUnit();
@@ -1551,49 +1551,49 @@ GeneralTokenStreamChars<CharT, AnyCharsA
         (unit != EOF); // subtract a get if it didn't contribute to length
 
     if (unit == '}' && (leadingZeroes > 0 || i > 0) && code <= unicode::NonBMPMax) {
         *codePoint = code;
         return gotten;
     }
 
     this->sourceUnits.unskipCodeUnits(gotten);
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
     return 0;
 }
 
 template<typename CharT, class AnyCharsAccess>
 uint32_t
 GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchUnicodeEscapeIdStart(uint32_t* codePoint)
 {
     uint32_t length = matchUnicodeEscape(codePoint);
     if (MOZ_LIKELY(length > 0)) {
         if (MOZ_LIKELY(unicode::IsIdentifierStart(*codePoint)))
             return length;
 
         this->sourceUnits.unskipCodeUnits(length);
     }
 
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
     return 0;
 }
 
 template<typename CharT, class AnyCharsAccess>
 bool
 GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchUnicodeEscapeIdent(uint32_t* codePoint)
 {
     uint32_t length = matchUnicodeEscape(codePoint);
     if (MOZ_LIKELY(length > 0)) {
         if (MOZ_LIKELY(unicode::IsIdentifierPart(*codePoint)))
             return true;
 
         this->sourceUnits.unskipCodeUnits(length);
     }
 
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
     return false;
 }
 
 template<typename CharT, class AnyCharsAccess>
 bool
 TokenStreamSpecific<CharT, AnyCharsAccess>::getDirectives(bool isMultiline,
                                                           bool shouldWarnDeprecated)
 {
@@ -2138,17 +2138,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
     newNumberToken(dval, decimalPoint, start, modifier, out);
     return true;
 }
 
 template<typename CharT, class AnyCharsAccess>
 MOZ_MUST_USE bool
 TokenStreamSpecific<CharT, AnyCharsAccess>::regexpLiteral(TokenStart start, TokenKind* out)
 {
-    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '/');
+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('/'));
     this->charBuffer.clear();
 
     auto ProcessNonAsciiCodePoint = [this](int32_t lead) {
         MOZ_ASSERT(lead != EOF);
         MOZ_ASSERT(!this->isAsciiCodePoint(lead));
 
         char32_t codePoint;
         if (!this->getNonAsciiCodePointDontNormalize(this->toCharT(lead), &codePoint))
@@ -2783,18 +2783,18 @@ TokenStreamSpecific<CharT, AnyCharsAcces
     auto noteBadToken = MakeScopeExit([this]() {
         this->badToken();
     });
 
     auto ReportPrematureEndOfLiteral = [this, untilChar](unsigned errnum) {
         // Unicode separators aren't end-of-line in template or (as of
         // recently) string literals, so this assertion doesn't allow them.
         MOZ_ASSERT(this->sourceUnits.atEnd() ||
-                   this->sourceUnits.peekCodeUnit() == '\r' ||
-                   this->sourceUnits.peekCodeUnit() == '\n',
+                   this->sourceUnits.peekCodeUnit() == CharT('\r') ||
+                   this->sourceUnits.peekCodeUnit() == CharT('\n'),
                    "must be parked at EOF or EOL to call this function");
 
         // The various errors reported here include language like "in a ''
         // literal" or similar, with '' being '', "", or `` as appropriate.
         const char delimiters[] = { untilChar, untilChar, '\0' };
 
         this->error(errnum, delimiters);
         return;