Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -432,6 +432,10 @@ } else if (CurrentToken->is(tok::r_square) && Parent && Parent->is(TT_TemplateCloser)) { Left->Type = TT_ArraySubscriptLSquare; + } else if (Style.Language == FormatStyle::LK_TableGen) { + // TableGen treats '[' as array subscripts to avoid spaces, e.g. + // def foo : Flag<["-", "--"], "foo">; + Left->Type = TT_ArraySubscriptLSquare; } else if (Style.Language == FormatStyle::LK_Proto || Style.Language == FormatStyle::LK_TextProto) { // Square braces in LK_Proto can either be message field attributes: Index: unittests/Format/FormatTestTableGen.cpp =================================================================== --- unittests/Format/FormatTestTableGen.cpp +++ unittests/Format/FormatTestTableGen.cpp @@ -52,5 +52,9 @@ " \"very long help string\">;\n"); } +TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) { + verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;\n"); +} + } // namespace format } // end namespace clang