[clang] [clang-format] Fix designated initializer detection (PR #169228)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 24 00:44:11 PST 2025


================
@@ -708,6 +708,11 @@ class AnnotatingParser {
         IsCpp && !IsCpp11AttributeSpecifier && !IsCSharpAttributeSpecifier &&
         Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
         CurrentToken->isNoneOf(tok::l_brace, tok::r_square) &&
+        // Do not consider '[' after a comma inside a braced initializer the
+        // start of an ObjC method expression. In braced initializer lists,
+        // commas are list separators and should not trigger ObjC parsing.
+        !(Parent && Parent->is(tok::comma) &&
+          Contexts.back().ContextKind == tok::l_brace) &&
----------------
HazardyKnusperkeks wrote:

```suggestion
        (!Parent || Parent->isNot(tok::comma) ||
          Contexts.back().ContextKind != tok::l_brace) &&
```
Same style as below.

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


More information about the cfe-commits mailing list