[clang] [clang-format] Fix a crash on triple-bracket input like `[[[a]]` (PR #199103)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 4 11:50:51 PDT 2026
================
@@ -90,6 +90,9 @@ static bool isCppAttribute(bool IsCpp, const FormatToken &Tok) {
// The first square bracket is part of an ObjC array literal
if (Tok.Previous && Tok.Previous->is(tok::at))
return false;
+ // Avoid mis-annotating the inner '[[' of malformed input.
+ if (Tok.Previous && Tok.Previous->is(tok::l_square))
----------------
HazardyKnusperkeks wrote:
```suggestion
if (Tok.Previous && Tok.Previous->isOneOf(tok::at, tok::l_square))
return false;
```
You can merge the comments.
https://github.com/llvm/llvm-project/pull/199103
More information about the cfe-commits
mailing list