[clang] [clang-format] Fix '!Scopes.empty()' assertion in parseBrace (PR #199098)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 5 22:41:12 PDT 2026


================
@@ -1214,9 +1214,11 @@ class AnnotatingParser {
 
     unsigned CommaCount = 0;
     while (CurrentToken) {
-      assert(!Scopes.empty());
+      if (Scopes.empty())
+        return false;
       if (CurrentToken->is(tok::r_brace)) {
-        assert(Scopes.back() == getScopeType(OpeningBrace));
+        if (Scopes.back() != getScopeType(OpeningBrace))
----------------
mygitljf wrote:

Yes, it happens — it's not just a defensive change. 
hit by `enum E { { ? } a }`

https://github.com/llvm/llvm-project/pull/199098


More information about the cfe-commits mailing list