Bug 1488698 - Always use braces for if/for/while statements in js/src/frontend, part 1. r=Yoric
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 06 Sep 2018 10:24:48 +0200
changeset 491451 6c382d4ab0d0deb714f15300afea2c52dff94e47
parent 491450 3fa402809570cf52220fd946081de01d7d117174
child 491452 f758714e4ed9a93b2db83be95fb669f53658a58b
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1488698
milestone64.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 1488698 - Always use braces for if/for/while statements in js/src/frontend, part 1. r=Yoric
js/src/frontend/BinSource.cpp
js/src/frontend/BinSource.h
js/src/frontend/BinSourceRuntimeSupport.h
js/src/frontend/BinToken.cpp
js/src/frontend/BinTokenReaderBase.cpp
js/src/frontend/BinTokenReaderBase.h
js/src/frontend/BinTokenReaderMultipart.cpp
js/src/frontend/BinTokenReaderMultipart.h
js/src/frontend/BinTokenReaderTester.cpp
js/src/frontend/BinTokenReaderTester.h
--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -125,57 +125,62 @@ template<typename Tok> JS::Result<ParseN
 BinASTParser<Tok>::parseAux(GlobalSharedContext* globalsc,
                             const uint8_t* start, const size_t length)
 {
     MOZ_ASSERT(globalsc);
 
     tokenizer_.emplace(cx_, start, length);
 
     BinParseContext globalpc(cx_, this, globalsc, /* newDirectives = */ nullptr);
-    if (!globalpc.init())
+    if (!globalpc.init()) {
         return cx_->alreadyReportedError();
+    }
 
     ParseContext::VarScope varScope(cx_, &globalpc, usedNames_);
-    if (!varScope.init(&globalpc))
+    if (!varScope.init(&globalpc)) {
         return cx_->alreadyReportedError();
+    }
 
     MOZ_TRY(tokenizer_->readHeader());
 
     ParseNode* result(nullptr);
     MOZ_TRY_VAR(result, parseProgram());
 
     mozilla::Maybe<GlobalScope::Data*> bindings = NewGlobalScopeData(cx_, varScope, alloc_,
                                                                      parseContext_);
-    if (!bindings)
+    if (!bindings) {
         return cx_->alreadyReportedError();
+    }
     globalsc->bindings = *bindings;
 
     return result; // Magic conversion to Ok.
 }
 
 
 template<typename Tok> JS::Result<FunctionBox*>
 BinASTParser<Tok>::buildFunctionBox(GeneratorKind generatorKind,
     FunctionAsyncKind functionAsyncKind,
     FunctionSyntaxKind syntax,
     ParseNode* name)
 {
     RootedAtom atom(cx_);
-    if (name)
+    if (name) {
         atom = name->name();
+    }
 
     // Allocate the function before walking down the tree.
     RootedFunction fun(cx_);
     BINJS_TRY_VAR(fun, AllocNewFunction(cx_, atom, syntax, generatorKind, functionAsyncKind, nullptr));
 
     auto* funbox = alloc_.new_<FunctionBox>(cx_, traceListHead_, fun, /* toStringStart = */ 0,
                                             Directives(parseContext_), /* extraWarning = */ false,
                                             generatorKind, functionAsyncKind);
-    if (!funbox)
+    if (!funbox) {
         return raiseOOM();
+    }
 
     traceListHead_ = funbox;
     funbox->initWithEnclosingParseContext(parseContext_, syntax);
     return funbox;
 }
 
 template<typename Tok> JS::Result<ParseNode*>
 BinASTParser<Tok>::buildFunction(const size_t start, const BinKind kind, ParseNode* name,
@@ -235,18 +240,19 @@ BinASTParser<Tok>::buildFunction(const s
     return result;
 }
 
 // Try to mark the capture in the given scope, if the variable exists.
 // Return whether it was found in this scope and marked successfully.
 static bool TryMarkCaptureInScope(ParseContext::Scope& scope, HandleAtom atom)
 {
     auto name = scope.lookupDeclaredName(atom);
-    if (!name)
+    if (!name) {
         return false;
+    }
     name->value()->setClosedOver();
     return true;
 }
 
 template<typename Tok> JS::Result<Ok>
 BinASTParser<Tok>::parseAndUpdateCapturedNames(const BinKind kind)
 {
     // For the moment, we do not attempt to validate the list of captured names.
@@ -258,32 +264,36 @@ BinASTParser<Tok>::parseAndUpdateCapture
     for (uint32_t i = 0; i < length; ++i) {
         name = nullptr;
 
         MOZ_TRY_VAR(name, tokenizer_->readAtom());
         if (kind == BinKind::AssertedParameterScope) {
             MOZ_ASSERT(parseContext_->isFunctionBox());
 
             if (parseContext_->functionBox()->function()->isNamedLambda()) {
-                if (TryMarkCaptureInScope(parseContext_->namedLambdaScope(), name))
+                if (TryMarkCaptureInScope(parseContext_->namedLambdaScope(), name)) {
                     continue;
+                }
             }
 
-            if (!TryMarkCaptureInScope(parseContext_->functionScope(), name))
+            if (!TryMarkCaptureInScope(parseContext_->functionScope(), name)) {
                 return raiseUndeclaredCapture(name);
+            }
             continue;
         }
 
         if (kind == BinKind::AssertedVarScope) {
-            if (TryMarkCaptureInScope(parseContext_->varScope(), name))
+            if (TryMarkCaptureInScope(parseContext_->varScope(), name)) {
                 continue;
+            }
         }
 
-        if (!TryMarkCaptureInScope(*parseContext_->innermostScope(), name))
+        if (!TryMarkCaptureInScope(*parseContext_->innermostScope(), name)) {
             return raiseUndeclaredCapture(name);
+        }
     }
     MOZ_TRY(guard.done());
     return Ok();
 }
 
 template<typename Tok> JS::Result<Ok>
 BinASTParser<Tok>::parseAndUpdateScopeNames(ParseContext::Scope& scope, DeclarationKind kind)
 {
@@ -292,18 +302,19 @@ BinASTParser<Tok>::parseAndUpdateScopeNa
 
     MOZ_TRY(tokenizer_->enterList(length, guard));
     RootedAtom name(cx_);
     for (uint32_t i = 0; i < length; ++i) {
         name = nullptr;
 
         MOZ_TRY_VAR(name, tokenizer_->readAtom());
         auto ptr = scope.lookupDeclaredNameForAdd(name);
-        if (ptr)
+        if (ptr) {
             return raiseError("Variable redeclaration");
+        }
 
         BINJS_TRY(scope.addDeclaredName(parseContext_, ptr, name.get(), kind, tokenizer_->offset()));
     }
     MOZ_TRY(guard.done());
     return Ok();
 }
 
 template<typename Tok> JS::Result<Ok>
@@ -311,46 +322,49 @@ BinASTParser<Tok>::checkBinding(JSAtom* 
 {
     // Check that the variable appears in the corresponding scope.
     ParseContext::Scope& scope =
         variableDeclarationKind_ == VariableDeclarationKind::Var
         ? parseContext_->varScope()
         : *parseContext_->innermostScope();
 
     auto ptr = scope.lookupDeclaredName(name->asPropertyName());
-    if (!ptr)
+    if (!ptr) {
         return raiseMissingVariableInAssertedScope(name);
+    }
 
     return Ok();
 }
 
 template<typename Tok> JS::Result<Ok>
 BinASTParser<Tok>::checkClosedVars(ParseContext::Scope& scope)
 {
     for (ParseContext::Scope::BindingIter bi = scope.bindings(parseContext_); bi; bi++) {
         if (UsedNamePtr p = usedNames_.lookup(bi.name())) {
             bool closedOver;
             p->value().noteBoundInScope(parseContext_->scriptId(), scope.id(), &closedOver);
-            if (closedOver && !bi.closedOver())
+            if (closedOver && !bi.closedOver()) {
                 return raiseInvalidClosedVar(bi.name());
+            }
         }
     }
 
     return Ok();
 }
 
 template<typename Tok> JS::Result<Ok>
 BinASTParser<Tok>::checkFunctionClosedVars()
 {
     MOZ_ASSERT(parseContext_->isFunctionBox());
 
     MOZ_TRY(checkClosedVars(*parseContext_->innermostScope()));
     MOZ_TRY(checkClosedVars(parseContext_->functionScope()));
-    if (parseContext_->functionBox()->function()->isNamedLambda())
+    if (parseContext_->functionBox()->function()->isNamedLambda()) {
         MOZ_TRY(checkClosedVars(parseContext_->namedLambdaScope()));
+    }
 
     return Ok();
 }
 
 template<typename Tok> JS::Result<ParseNode*>
 BinASTParser<Tok>::appendDirectivesToBody(ParseNode* body, ParseNode* directives)
 {
     ParseNode* result = body;
@@ -495,18 +509,19 @@ BinASTParser<Tok>::errorAtVA(uint32_t of
     metadata.columnNumber = offset;
     metadata.isMuted = options().mutedErrors();
     ReportCompileError(cx_, std::move(metadata), nullptr, JSREPORT_ERROR, errorNumber, *args);
 }
 
 template<typename Tok> bool
 BinASTParser<Tok>::reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset, unsigned errorNumber, va_list* args)
 {
-    if (!options().extraWarningsOption)
+    if (!options().extraWarningsOption) {
         return true;
+    }
 
     ErrorMetadata metadata;
     metadata.filename = getFilename();
     metadata.lineNumber = 0;
     metadata.columnNumber = offset;
     metadata.isMuted = options().mutedErrors();
 
     if (options().werrorOption) {
@@ -515,18 +530,19 @@ BinASTParser<Tok>::reportExtraWarningErr
     }
 
     return ReportCompileWarning(cx_, std::move(metadata), std::move(notes), JSREPORT_STRICT | JSREPORT_WARNING, errorNumber, *args);
 }
 
 bool
 BinASTParserBase::hasUsedName(HandlePropertyName name)
 {
-    if (UsedNamePtr p = usedNames_.lookup(name))
+    if (UsedNamePtr p = usedNames_.lookup(name)) {
         return p->value().isUsedInScript(parseContext_->scriptId());
+    }
 
     return false;
 }
 
 void
 TraceBinParser(JSTracer* trc, JS::AutoGCRooter* parser)
 {
     static_cast<BinASTParserBase*>(parser)->trace(trc);
--- a/js/src/frontend/BinSource.h
+++ b/js/src/frontend/BinSource.h
@@ -237,29 +237,31 @@ class BinASTParser : public BinASTParser
     virtual uint32_t lineAt(size_t offset) const override {
         return 0;
     }
     virtual uint32_t columnAt(size_t offset) const override {
         return offset;
     }
 
     virtual bool isOnThisLine(size_t offset, uint32_t lineNum, bool *isOnSameLine) const override {
-        if (lineNum != 0)
+        if (lineNum != 0) {
             return false;
+        }
         *isOnSameLine = true;
         return true;
     }
 
     virtual void currentLineAndColumn(uint32_t* line, uint32_t* column) const override {
         *line = 0;
         *column = offset();
     }
     size_t offset() const {
-        if (tokenizer_.isSome())
+        if (tokenizer_.isSome()) {
             return tokenizer_->offset();
+        }
 
         return 0;
     }
     virtual bool hasTokenizationStarted() const override {
         return tokenizer_.isSome();
     }
     virtual void reportErrorNoOffsetVA(unsigned errorNumber, va_list args) override;
     virtual void errorAtVA(uint32_t offset, unsigned errorNumber, va_list* args) override;
--- a/js/src/frontend/BinSourceRuntimeSupport.h
+++ b/js/src/frontend/BinSourceRuntimeSupport.h
@@ -39,30 +39,32 @@ struct BinaryASTSupport {
         const char* begin() const {
             return start_;
         }
         const char* end() const {
             return start_ + byteLen_;
         }
 #ifdef DEBUG
         void dump() const {
-            for (auto c: *this)
+            for (auto c: *this) {
                 fprintf(stderr, "%c", c);
+            }
 
             fprintf(stderr, " (%d)", byteLen_);
         }
 #endif // DEBUG
 
         typedef const CharSlice Lookup;
         static js::HashNumber hash(Lookup l) {
             return mozilla::HashString(l.start_, l.byteLen_);
         }
         static bool match(const Lookup key, Lookup lookup) {
-            if (key.byteLen_ != lookup.byteLen_)
+            if (key.byteLen_ != lookup.byteLen_) {
                 return false;
+            }
             return strncmp(key.start_, lookup.start_, key.byteLen_) == 0;
         }
     };
 
     BinaryASTSupport();
 
     JS::Result<const BinVariant*>  binVariant(JSContext*, const CharSlice);
     JS::Result<const BinField*> binField(JSContext*, const CharSlice);
--- a/js/src/frontend/BinToken.cpp
+++ b/js/src/frontend/BinToken.cpp
@@ -82,43 +82,47 @@ JS::Result<const js::frontend::BinKind*>
 BinaryASTSupport::binKind(JSContext* cx, const CharSlice key)
 {
     if (binKindMap_.empty()) {
         for (size_t i = 0; i < frontend::BINKIND_LIMIT; ++i) {
             const BinKind variant = static_cast<BinKind>(i);
             const CharSlice& key = getBinKind(variant);
             auto ptr = binKindMap_.lookupForAdd(key);
             MOZ_ASSERT(!ptr);
-            if (!binKindMap_.add(ptr, key, variant))
+            if (!binKindMap_.add(ptr, key, variant)) {
                 return ReportOutOfMemoryResult(cx);
+            }
         }
     }
 
     auto ptr = binKindMap_.lookup(key);
-    if (!ptr)
+    if (!ptr) {
         return nullptr;
+    }
 
     return &ptr->value();
 }
 
 JS::Result<const js::frontend::BinVariant*>
 BinaryASTSupport::binVariant(JSContext* cx, const CharSlice key)
 {
     if (binVariantMap_.empty()) {
         for (size_t i = 0; i < frontend::BINVARIANT_LIMIT; ++i) {
             const BinVariant variant = static_cast<BinVariant>(i);
             const CharSlice& key = getBinVariant(variant);
             auto ptr = binVariantMap_.lookupForAdd(key);
             MOZ_ASSERT(!ptr);
-            if (!binVariantMap_.add(ptr, key, variant))
+            if (!binVariantMap_.add(ptr, key, variant)) {
                 return ReportOutOfMemoryResult(cx);
+            }
         }
     }
 
 
     auto ptr = binVariantMap_.lookup(key);
-    if (!ptr)
+    if (!ptr) {
         return nullptr;
+    }
 
     return &ptr->value();
 }
 
 } // namespace js
--- a/js/src/frontend/BinTokenReaderBase.cpp
+++ b/js/src/frontend/BinTokenReaderBase.cpp
@@ -94,21 +94,23 @@ BinTokenReaderBase::pos(size_t start)
 }
 
 JS::Result<Ok>
 BinTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len)
 {
     MOZ_ASSERT(!cx_->isExceptionPending());
     MOZ_ASSERT(len > 0);
 
-    if (stop_ < current_ + len)
+    if (stop_ < current_ + len) {
         return raiseError("Buffer exceeds length");
+    }
 
-    for (uint32_t i = 0; i < len; ++i)
+    for (uint32_t i = 0; i < len; ++i) {
         *bytes++ = *current_++;
+    }
 
     return Ok();
 }
 
 JS::Result<uint8_t>
 BinTokenReaderBase::readByte()
 {
     uint8_t byte;
--- a/js/src/frontend/BinTokenReaderBase.h
+++ b/js/src/frontend/BinTokenReaderBase.h
@@ -100,18 +100,19 @@ class MOZ_STACK_CLASS BinTokenReaderBase
      * sequence of chars.
      *
      * @param value The sequence of chars to expect, NUL-terminated.
      */
      template <size_t N>
      MOZ_MUST_USE JS::Result<Ok> readConst(const char (&value)[N])
      {
         updateLatestKnownGood();
-        if (!matchConst(value, false))
+        if (!matchConst(value, false)) {
             return raiseError("Could not find expected literal");
+        }
         return Ok();
      }
 
      /**
      * Read a sequence of chars, consuming the bytes only if they match an expected
      * sequence of chars.
      *
      * @param value The sequence of chars to expect, NUL-terminated.
@@ -121,22 +122,24 @@ class MOZ_STACK_CLASS BinTokenReaderBase
      * otherwise there is no side-effect.
      */
     template <size_t N>
     MOZ_MUST_USE bool matchConst(const char (&value)[N], bool expectNul) {
         MOZ_ASSERT(N > 0);
         MOZ_ASSERT(value[N - 1] == 0);
         MOZ_ASSERT(!hasRaisedError());
 
-        if (current_ + N - 1 > stop_)
+        if (current_ + N - 1 > stop_) {
             return false;
+        }
 
         // Perform lookup, without side-effects.
-        if (!std::equal(current_, current_ + N + (expectNul ? 0 : -1)/*implicit NUL*/, value))
+        if (!std::equal(current_, current_ + N + (expectNul ? 0 : -1)/*implicit NUL*/, value)) {
             return false;
+        }
 
         // Looks like we have a match. Now perform side-effects
         current_ += N + (expectNul ? 0 : -1);
         updateLatestKnownGood();
         return true;
     }
 
     void updateLatestKnownGood();
--- a/js/src/frontend/BinTokenReaderMultipart.cpp
+++ b/js/src/frontend/BinTokenReaderMultipart.cpp
@@ -61,80 +61,93 @@ BinTokenReaderMultipart::readHeader()
 
     // Read global headers.
     MOZ_TRY(readConst(MAGIC_HEADER));
     BINJS_MOZ_TRY_DECL(version, readInternalUint32());
 
     // For the moment, MAGIC_FORMAT_VERSION is 0. Once we have a story
     // on backwards compatibility of the binary container, we will
     // probably want to change this to `if (version > MAGIC_FORMAT_VERSION)`.
-    if (version != MAGIC_FORMAT_VERSION)
+    if (version != MAGIC_FORMAT_VERSION) {
         return raiseError("Format version not implemented");
+    }
 
     // Start reading grammar.
     MOZ_TRY(readConst(SECTION_HEADER_GRAMMAR));
     MOZ_TRY(readConst(COMPRESSION_IDENTITY)); // For the moment, we only support identity compression.
     BINJS_MOZ_TRY_DECL(grammarByteLen, readInternalUint32());
     const auto posBeforeGrammar = current_;
 
-    if (posBeforeGrammar + grammarByteLen > stop_ || posBeforeGrammar + grammarByteLen < current_) // Sanity check.
+    if (posBeforeGrammar + grammarByteLen > stop_ || posBeforeGrammar + grammarByteLen < current_) { // Sanity check.
         return raiseError("Invalid byte length in grammar table");
+    }
 
     BINJS_MOZ_TRY_DECL(grammarNumberOfEntries, readInternalUint32());
-    if (grammarNumberOfEntries > BINKIND_LIMIT) // Sanity check.
+    if (grammarNumberOfEntries > BINKIND_LIMIT) { // Sanity check.
         return raiseError("Invalid number of entries in grammar table");
+    }
 
     // This table maps BinKind index -> BinKind.
     // Initialize and populate.
-    if (!grammarTable_.reserve(grammarNumberOfEntries))
+    if (!grammarTable_.reserve(grammarNumberOfEntries)) {
         return raiseOOM();
+    }
 
     for (uint32_t i = 0; i < grammarNumberOfEntries; ++i) {
         BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
-        if (current_ + byteLen > stop_)
+        if (current_ + byteLen > stop_) {
             return raiseError("Invalid byte length in grammar table");
-        if (current_ + byteLen < current_) // Overflow.
+        }
+        if (current_ + byteLen < current_) { // Overflow.
             return raiseError("Invalid byte length in grammar table");
+        }
         CharSlice name((const char*)current_, byteLen);
         current_ += byteLen;
 
         BINJS_MOZ_TRY_DECL(kind, cx_->runtime()->binast().binKind(cx_, name));
-        if (!kind)
+        if (!kind) {
             return raiseError("Invalid entry in grammar table");
+        }
 
         grammarTable_.infallibleAppend(*kind); // We called `reserve` before the loop.
     }
-    if (current_ != grammarByteLen + posBeforeGrammar)
+    if (current_ != grammarByteLen + posBeforeGrammar) {
         return raiseError("The length of the grammar table didn't match its contents.");
+    }
 
     // Start reading strings
     MOZ_TRY(readConst(SECTION_HEADER_STRINGS));
     MOZ_TRY(readConst(COMPRESSION_IDENTITY)); // For the moment, we only support identity compression.
     BINJS_MOZ_TRY_DECL(stringsByteLen, readInternalUint32());
     const auto posBeforeStrings = current_;
 
-    if (posBeforeStrings + stringsByteLen > stop_ || posBeforeStrings + stringsByteLen < current_) // Sanity check.
+    if (posBeforeStrings + stringsByteLen > stop_ || posBeforeStrings + stringsByteLen < current_) { // Sanity check.
         return raiseError("Invalid byte length in strings table");
+    }
 
     BINJS_MOZ_TRY_DECL(stringsNumberOfEntries, readInternalUint32());
-    if (stringsNumberOfEntries > MAX_NUMBER_OF_STRINGS) // Sanity check.
+    if (stringsNumberOfEntries > MAX_NUMBER_OF_STRINGS) { // Sanity check.
         return raiseError("Too many entries in strings table");
+    }
 
     // This table maps String index -> String.
     // Initialize and populate.
-    if (!atomsTable_.reserve(stringsNumberOfEntries))
+    if (!atomsTable_.reserve(stringsNumberOfEntries)) {
         return raiseOOM();
-    if (!slicesTable_.reserve(stringsNumberOfEntries))
+    }
+    if (!slicesTable_.reserve(stringsNumberOfEntries)) {
         return raiseOOM();
+    }
 
     RootedAtom atom(cx_);
     for (uint32_t i = 0; i < stringsNumberOfEntries; ++i) {
         BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
-        if (current_ + byteLen > stop_ || current_ + byteLen < current_)
+        if (current_ + byteLen > stop_ || current_ + byteLen < current_) {
             return raiseError("Invalid byte length in individual string");
+        }
 
         // Check null string.
         if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
             atom = nullptr;
         } else {
             BINJS_TRY_VAR(atom, Atomize(cx_, (const char*)current_, byteLen));
         }
 
@@ -143,28 +156,30 @@ BinTokenReaderMultipart::readHeader()
 
         // Populate `slicesTable_`: i => slice
         Chars slice((const char*)current_, byteLen);
         slicesTable_.infallibleAppend(std::move(slice)); // We have reserved before entering the loop.
 
         current_ += byteLen;
     }
 
-    if (posBeforeStrings + stringsByteLen != current_)
+    if (posBeforeStrings + stringsByteLen != current_) {
         return raiseError("The length of the strings table didn't match its contents.");
+    }
 
     // Start reading AST.
     MOZ_TRY(readConst(SECTION_HEADER_TREE));
     MOZ_TRY(readConst(COMPRESSION_IDENTITY)); // For the moment, we only support identity compression.
     posBeforeTree_ = current_;
 
     BINJS_MOZ_TRY_DECL(treeByteLen, readInternalUint32());
 
-    if (posBeforeTree_ + treeByteLen > stop_ || posBeforeTree_ + treeByteLen < posBeforeTree_) // Sanity check.
+    if (posBeforeTree_ + treeByteLen > stop_ || posBeforeTree_ + treeByteLen < posBeforeTree_) { // Sanity check.
         return raiseError("Invalid byte length in tree table");
+    }
 
     // At this stage, we're ready to start reading the tree.
     return Ok();
 }
 
 JS::Result<bool>
 BinTokenReaderMultipart::readBool()
 {
@@ -194,100 +209,109 @@ BinTokenReaderMultipart::readDouble()
 
     uint8_t bytes[8];
     MOZ_ASSERT(sizeof(bytes) == sizeof(double));
     MOZ_TRY(readBuf(reinterpret_cast<uint8_t*>(bytes), mozilla::ArrayLength(bytes)));
 
     // Decode little-endian.
     const uint64_t asInt = mozilla::LittleEndian::readUint64(bytes);
 
-    if (asInt == NULL_FLOAT_REPRESENTATION)
+    if (asInt == NULL_FLOAT_REPRESENTATION) {
         return raiseError("Not implemented: null double value");
+    }
 
     // Canonicalize NaN, just to make sure another form of signalling NaN
     // doesn't slip past us.
     return JS::CanonicalizeNaN(mozilla::BitwiseCast<double>(asInt));
 }
 
 
 // A single atom is represented as an index into the table of strings.
 JS::Result<JSAtom*>
 BinTokenReaderMultipart::readMaybeAtom()
 {
     updateLatestKnownGood();
     BINJS_MOZ_TRY_DECL(index, readInternalUint32());
 
-    if (index >= atomsTable_.length())
+    if (index >= atomsTable_.length()) {
         return raiseError("Invalid index to strings table");
+    }
     return atomsTable_[index].get();
 }
 
 JS::Result<JSAtom*>
 BinTokenReaderMultipart::readAtom()
 {
     BINJS_MOZ_TRY_DECL(maybe, readMaybeAtom());
 
-    if (!maybe)
+    if (!maybe) {
         return raiseError("Empty string");
+    }
 
     return maybe;
 }
 
 JS::Result<Ok>
 BinTokenReaderMultipart::readChars(Chars& out)
 {
     updateLatestKnownGood();
     BINJS_MOZ_TRY_DECL(index, readInternalUint32());
 
-    if (index >= slicesTable_.length())
+    if (index >= slicesTable_.length()) {
         return raiseError("Invalid index to strings table for string enum");
+    }
 
     out = slicesTable_[index];
     return Ok();
 }
 
 JS::Result<BinVariant>
 BinTokenReaderMultipart::readVariant()
 {
     updateLatestKnownGood();
     BINJS_MOZ_TRY_DECL(index, readInternalUint32());
 
-    if (index >= slicesTable_.length())
+    if (index >= slicesTable_.length()) {
         return raiseError("Invalid index to strings table for string enum");
+    }
 
     auto variantsPtr = variantsTable_.lookupForAdd(index);
-    if (variantsPtr)
+    if (variantsPtr) {
         return variantsPtr->value();
+    }
 
     // Either we haven't cached the result yet or this is not a variant.
     // Check in the slices table and, in case of success, cache the result.
 
     // Note that we stop parsing if we attempt to readVariant() with an
     // ill-formed variant, so we don't run the risk of feching an ill-variant
     // more than once.
     Chars slice = slicesTable_[index]; // We have checked `index` above.
     BINJS_MOZ_TRY_DECL(variant, cx_->runtime()->binast().binVariant(cx_, slice));
 
-    if (!variant)
+    if (!variant) {
         return raiseError("Invalid string enum variant");
+    }
 
-    if (!variantsTable_.add(variantsPtr, index, *variant))
+    if (!variantsTable_.add(variantsPtr, index, *variant)) {
         return raiseOOM();
+    }
 
     return *variant;
 }
 
 JS::Result<BinTokenReaderBase::SkippableSubTree>
 BinTokenReaderMultipart::readSkippableSubTree()
 {
     updateLatestKnownGood();
     BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
 
-    if (current_ + byteLen > stop_ || current_ + byteLen < current_)
+    if (current_ + byteLen > stop_ || current_ + byteLen < current_) {
         return raiseError("Invalid byte length in readSkippableSubTree");
+    }
 
     const auto start = current_;
 
     current_ += byteLen;
 
     return BinTokenReaderBase::SkippableSubTree(start, byteLen);
 }
 
@@ -303,18 +327,19 @@ BinTokenReaderMultipart::enterUntaggedTu
 
 // Tagged tuples:
 // - uint32_t index in table [grammar];
 // - content (specified by the higher-level grammar);
 JS::Result<Ok>
 BinTokenReaderMultipart::enterTaggedTuple(BinKind& tag, BinTokenReaderMultipart::BinFields&, AutoTaggedTuple& guard)
 {
     BINJS_MOZ_TRY_DECL(index, readInternalUint32());
-    if (index >= grammarTable_.length())
+    if (index >= grammarTable_.length()) {
         return raiseError("Invalid index to grammar table");
+    }
 
     tag = grammarTable_[index];
 
     // Enter the body.
     guard.init();
     return Ok();
 }
 
@@ -351,18 +376,19 @@ BinTokenReaderMultipart::AutoBase::~Auto
     // The only case in which we can accept not calling `done()` is if we have
     // bailed out because of an error.
     MOZ_ASSERT_IF(initialized_, reader_.cx_->isExceptionPending());
 }
 
 JS::Result<Ok>
 BinTokenReaderMultipart::AutoBase::checkPosition(const uint8_t* expectedEnd)
 {
-    if (reader_.current_ != expectedEnd)
+    if (reader_.current_ != expectedEnd) {
         return reader_.raiseError("Caller did not consume the expected set of bytes");
+    }
 
     return Ok();
 }
 
 
 
 BinTokenReaderMultipart::AutoList::AutoList(BinTokenReaderMultipart& reader)
     : AutoBase(reader)
@@ -398,18 +424,19 @@ BinTokenReaderMultipart::readInternalUin
     uint32_t result = 0;
     uint32_t shift  = 0;
     while (true) {
         MOZ_ASSERT(shift < 32);
         uint32_t byte;
         MOZ_TRY_VAR(byte, readByte());
 
         const uint32_t newResult = result | (byte >> 1) << shift;
-        if (newResult < result)
+        if (newResult < result) {
             return raiseError("Overflow during readInternalUint32");
+        }
 
         result = newResult;
         shift += 7;
 
         if ((byte & 1) == 0) {
             return result;
         }
     }
--- a/js/src/frontend/BinTokenReaderMultipart.h
+++ b/js/src/frontend/BinTokenReaderMultipart.h
@@ -274,21 +274,23 @@ class MOZ_STACK_CLASS BinTokenReaderMult
         MOZ_MUST_USE JS::Result<Ok> done();
     };
 
     // Compare a `Chars` and a string literal (ONLY a string literal).
     template <size_t N>
     static bool equals(const Chars& left, const char (&right)[N]) {
         MOZ_ASSERT(N > 0);
         MOZ_ASSERT(right[N - 1] == 0);
-        if (left.byteLen_ + 1 /* implicit NUL */ != N)
+        if (left.byteLen_ + 1 /* implicit NUL */ != N) {
             return false;
+        }
 
-        if (!std::equal(left.start_, left.start_ + left.byteLen_, right))
+        if (!std::equal(left.start_, left.start_ + left.byteLen_, right)) {
           return false;
+        }
 
         return true;
     }
 
     template<size_t N>
     static JS::Result<Ok, JS::Error&>
     checkFields(const BinKind kind, const BinFields& actual, const BinField (&expected)[N]) {
       // Not implemented in this tokenizer.
--- a/js/src/frontend/BinTokenReaderTester.cpp
+++ b/js/src/frontend/BinTokenReaderTester.cpp
@@ -68,18 +68,19 @@ BinTokenReaderTester::readDouble()
 
     uint8_t bytes[8];
     MOZ_ASSERT(sizeof(bytes) == sizeof(double));
     MOZ_TRY(readBuf(reinterpret_cast<uint8_t*>(bytes), mozilla::ArrayLength(bytes)));
 
     // Decode little-endian.
     const uint64_t asInt = mozilla::LittleEndian::readUint64(bytes);
 
-    if (asInt == NULL_FLOAT_REPRESENTATION)
+    if (asInt == NULL_FLOAT_REPRESENTATION) {
         return raiseError("Not implemented: null double value");
+    }
 
     // Canonicalize NaN, just to make sure another form of signalling NaN
     // doesn't slip past us.
     return JS::CanonicalizeNaN(mozilla::BitwiseCast<double>(asInt));
 }
 
 // Internal uint32_t
 //
@@ -113,21 +114,23 @@ BinTokenReaderTester::readMaybeAtom()
     MOZ_TRY(readConst("<string>"));
 
     RootedAtom result(cx_);
 
     // 1. Read byteLength
     BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
 
     // 2. Reject if we can't read
-    if (current_ + byteLen < current_) // Check for overflows
+    if (current_ + byteLen < current_) { // Check for overflows
         return raiseError("Arithmetics overflow: string is too long");
+    }
 
-    if (current_ + byteLen > stop_)
+    if (current_ + byteLen > stop_) {
         return raiseError("Not enough bytes to read chars");
+    }
 
     if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
         // 3. Special case: null string.
         result = nullptr;
     } else {
         // 4. Other strings (bytes are copied)
         BINJS_TRY_VAR(result, Atomize(cx_, (const char*)current_, byteLen));
     }
@@ -152,87 +155,95 @@ BinTokenReaderTester::readChars(Chars& o
     updateLatestKnownGood();
 
     MOZ_TRY(readConst("<string>"));
 
     // 1. Read byteLength
     BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
 
     // 2. Reject if we can't read
-    if (current_ + byteLen < current_) // Check for overflows
+    if (current_ + byteLen < current_) { // Check for overflows
         return raiseError("Arithmetics overflow: string is too long");
+    }
 
-    if (current_ + byteLen > stop_)
+    if (current_ + byteLen > stop_) {
         return raiseError("Not enough bytes to read chars");
+    }
 
     if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
         // 3. Special case: null string.
         return raiseError("Empty string");
     }
 
     // 4. Other strings (bytes are copied)
-    if (!out.resize(byteLen))
+    if (!out.resize(byteLen)) {
         return raiseOOM();
+    }
 
     mozilla::PodCopy(out.begin(), current_, byteLen);
 
     current_ += byteLen;
 
     MOZ_TRY(readConst("</string>"));
     return Ok();
 }
 
 JS::Result<JSAtom*>
 BinTokenReaderTester::readAtom()
 {
     RootedAtom atom(cx_);
     MOZ_TRY_VAR(atom, readMaybeAtom());
 
-    if (!atom)
+    if (!atom) {
         return raiseError("Empty string");
+    }
     return atom.get();
 }
 
 JS::Result<BinVariant>
 BinTokenReaderTester::readVariant()
 {
     MOZ_TRY(readConst("<string>"));
     BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
 
     // 2. Reject if we can't read
-    if (current_ + byteLen < current_) // Check for overflows
+    if (current_ + byteLen < current_) { // Check for overflows
         return raiseError("Arithmetics overflow: string is too long");
+    }
 
-    if (current_ + byteLen > stop_)
+    if (current_ + byteLen > stop_) {
         return raiseError("Not enough bytes to read chars");
+    }
 
     if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
         // 3. Special case: null string.
         return raiseError("Empty variant");
     }
 
     BinaryASTSupport::CharSlice slice((const char*)current_, byteLen);
     current_ += byteLen;
 
     BINJS_MOZ_TRY_DECL(variant, cx_->runtime()->binast().binVariant(cx_, slice));
-    if (!variant)
+    if (!variant) {
         return raiseError("Not a variant");
+    }
 
     MOZ_TRY(readConst("</string>"));
     return *variant;
 }
 
 JS::Result<BinTokenReaderBase::SkippableSubTree>
 BinTokenReaderTester::readSkippableSubTree()
 {
     updateLatestKnownGood();
     BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
 
-    if (current_ + byteLen > stop_ || current_ + byteLen < current_)
+    if (current_ + byteLen > stop_ || current_ + byteLen < current_) {
         return raiseError("Invalid byte length in readSkippableSubTree");
+    }
 
     const auto start = current_;
 
     current_ += byteLen;
 
     return BinTokenReaderBase::SkippableSubTree(start, byteLen);
 }
 
@@ -281,18 +292,19 @@ BinTokenReaderTester::enterTaggedTuple(B
         // else
         return raiseError("Invalid tag");
     } while(false);
 
     // Now fields.
     BINJS_MOZ_TRY_DECL(fieldNum, readInternalUint32());
 
     fields.clear();
-    if (!fields.reserve(fieldNum))
+    if (!fields.reserve(fieldNum)) {
         return raiseOOM();
+    }
 
     for (uint32_t i = 0; i < fieldNum; ++i) {
         // This would probably be much faster with a HashTable, but we don't
         // really care about the speed of BinTokenReaderTester.
         BinField field;
         do {
 
 #define FIND_MATCH(CONSTRUCTOR, NAME) \
@@ -364,18 +376,19 @@ BinTokenReaderTester::AutoBase::~AutoBas
     // The only case in which we can accept not calling `done()` is if we have
     // bailed out because of an error.
     MOZ_ASSERT_IF(initialized_, reader_.cx_->isExceptionPending());
 }
 
 JS::Result<Ok>
 BinTokenReaderTester::AutoBase::checkPosition(const uint8_t* expectedEnd)
 {
-    if (reader_.current_ != expectedEnd)
+    if (reader_.current_ != expectedEnd) {
         return reader_.raiseError("Caller did not consume the expected set of bytes");
+    }
 
     return Ok();
 }
 
 BinTokenReaderTester::AutoList::AutoList(BinTokenReaderTester& reader)
     : AutoBase(reader)
 { }
 
--- a/js/src/frontend/BinTokenReaderTester.h
+++ b/js/src/frontend/BinTokenReaderTester.h
@@ -271,46 +271,51 @@ class MOZ_STACK_CLASS BinTokenReaderTest
         MOZ_MUST_USE JS::Result<Ok> done();
     };
 
     // Compare a `Chars` and a string literal (ONLY a string literal).
     template <size_t N>
     static bool equals(const Chars& left, const char (&right)[N]) {
         MOZ_ASSERT(N > 0);
         MOZ_ASSERT(right[N - 1] == 0);
-        if (left.length() + 1 /* implicit NUL */ != N)
+        if (left.length() + 1 /* implicit NUL */ != N) {
             return false;
+        }
 
-        if (!std::equal(left.begin(), left.end(), right))
+        if (!std::equal(left.begin(), left.end(), right)) {
           return false;
+        }
 
         return true;
     }
 
     // Ensure that we are visiting the right fields.
     template<size_t N>
     JS::Result<Ok, JS::Error&> checkFields(const BinKind kind, const BinFields& actual,
                                                   const BinField (&expected)[N])
     {
-        if (actual.length() != N)
+        if (actual.length() != N) {
             return raiseInvalidNumberOfFields(kind, N, actual.length());
+        }
 
         for (size_t i = 0; i < N; ++i) {
-            if (actual[i] != expected[i])
+            if (actual[i] != expected[i]) {
                 return raiseInvalidField(describeBinKind(kind), actual[i]);
+            }
         }
 
         return Ok();
     }
 
     // Special case for N=0, as empty arrays are not permitted in C++
     JS::Result<Ok, JS::Error&> checkFields0(const BinKind kind, const BinFields& actual)
     {
-        if (actual.length() != 0)
+        if (actual.length() != 0) {
             return raiseInvalidNumberOfFields(kind, 0, actual.length());
+        }
 
         return Ok();
     }
 };
 
 } // namespace frontend
 } // namespace js