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

via cfe-commits cfe-commits at lists.llvm.org
Sat May 23 06:29:19 PDT 2026


================
@@ -1297,6 +1297,11 @@ class AnnotatingParser {
         next();
         return true;
       }
+      // Avoid consuming an unbalanced `}` here: it would pop a Scopes frame
+      // owned by an enclosing parseBrace and trip its `!Scopes.empty()`
+      // assertion. See Issue #199017.
+      if (CurrentToken->is(tok::r_brace))
----------------
mygitljf wrote:

You’re right, this is definitely the better approach.
I moved the fix to where the assert actually fires . Now no matter what path drains the Scopes stack, parseBrace will just bail out gracefully instead of crashing.

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


More information about the cfe-commits mailing list