rupprecht updated this revision to Diff 180882. rupprecht added a comment. Move TableGen language check to where SpacesInContainerLiterals is checked
Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55964/new/ https://reviews.llvm.org/D55964 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestTableGen.cpp 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 Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2486,12 +2486,13 @@ return false; const auto SpaceRequiredForArrayInitializerLSquare = [](const FormatToken &LSquareTok, const FormatStyle &Style) { - return Style.SpacesInContainerLiterals || - ((Style.Language == FormatStyle::LK_Proto || - Style.Language == FormatStyle::LK_TextProto) && - !Style.Cpp11BracedListStyle && - LSquareTok.endsSequence(tok::l_square, tok::colon, - TT_SelectorName)); + return Style.Language != FormatStyle::LK_TableGen && + (Style.SpacesInContainerLiterals || + ((Style.Language == FormatStyle::LK_Proto || + Style.Language == FormatStyle::LK_TextProto) && + !Style.Cpp11BracedListStyle && + LSquareTok.endsSequence(tok::l_square, tok::colon, + TT_SelectorName))); }; if (Left.is(tok::l_square)) return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
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 Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2486,12 +2486,13 @@ return false; const auto SpaceRequiredForArrayInitializerLSquare = [](const FormatToken &LSquareTok, const FormatStyle &Style) { - return Style.SpacesInContainerLiterals || - ((Style.Language == FormatStyle::LK_Proto || - Style.Language == FormatStyle::LK_TextProto) && - !Style.Cpp11BracedListStyle && - LSquareTok.endsSequence(tok::l_square, tok::colon, - TT_SelectorName)); + return Style.Language != FormatStyle::LK_TableGen && + (Style.SpacesInContainerLiterals || + ((Style.Language == FormatStyle::LK_Proto || + Style.Language == FormatStyle::LK_TextProto) && + !Style.Cpp11BracedListStyle && + LSquareTok.endsSequence(tok::l_square, tok::colon, + TT_SelectorName))); }; if (Left.is(tok::l_square)) return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits