[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:56 PDT 2026


================
@@ -90,6 +90,12 @@ 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;
+  // A C++ attribute specifier '[[...]]' never appears directly inside another
+  // '['. Treating malformed input like '[[[a]]' as one would mis-annotate the
+  // inner '[' as TT_AttributeLSquare while leaving the outer '[' as a raw
+  // tok::l_square, tripping an assertion in canBreakBefore.
+  if (Tok.Previous && Tok.Previous->is(tok::l_square))
----------------
HazardyKnusperkeks wrote:

Okay.

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


More information about the cfe-commits mailing list