atirit updated this revision to Diff 314149. atirit added a comment. Fixed the FormatTest.ShortEnums unit test and fixed compatibility with `FormatTestCSharp.CSharpKeyWordEscaping` and `FormatTestJS.EnumDeclarations`
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93938/new/ https://reviews.llvm.org/D93938 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -1344,8 +1344,7 @@ Style.AllowShortEnumsOnASingleLine = true; verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style); Style.AllowShortEnumsOnASingleLine = false; - verifyFormat("enum\n" - "{\n" + verifyFormat("enum {\n" " A,\n" " B,\n" " C\n" Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1301,7 +1301,7 @@ if (!parseEnum()) break; // This only applies for C++. - if (!Style.isCpp() && Style.BraceWrapping.AfterEnum) { + if (!Style.isCpp()) { addUnwrappedLine(); return; } @@ -2484,6 +2484,9 @@ return true; } + if (!Style.AllowShortEnumsOnASingleLine && Style.BraceWrapping.AfterEnum) + addUnwrappedLine(); + // Parse enum body. nextToken(); if (!Style.AllowShortEnumsOnASingleLine) {
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -1344,8 +1344,7 @@ Style.AllowShortEnumsOnASingleLine = true; verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style); Style.AllowShortEnumsOnASingleLine = false; - verifyFormat("enum\n" - "{\n" + verifyFormat("enum {\n" " A,\n" " B,\n" " C\n" Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1301,7 +1301,7 @@ if (!parseEnum()) break; // This only applies for C++. - if (!Style.isCpp() && Style.BraceWrapping.AfterEnum) { + if (!Style.isCpp()) { addUnwrappedLine(); return; } @@ -2484,6 +2484,9 @@ return true; } + if (!Style.AllowShortEnumsOnASingleLine && Style.BraceWrapping.AfterEnum) + addUnwrappedLine(); + // Parse enum body. nextToken(); if (!Style.AllowShortEnumsOnASingleLine) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits