This revision was automatically updated to reflect the committed changes. Closed by commit rG072ae7c1e64f: [clang-format] Always break line after enum opening brace (authored by MyDeveloperDay, committed by paulhoad <paul.h...@gmail.com>).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77682/new/ https://reviews.llvm.org/D77682 Files: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -1929,6 +1929,24 @@ " TWO\n" "};\n" "int i;"); + + FormatStyle EightIndent = getLLVMStyle(); + EightIndent.IndentWidth = 8; + verifyFormat("enum {\n" + " VOID,\n" + " CHAR,\n" + " SHORT,\n" + " INT,\n" + " LONG,\n" + " SIGNED,\n" + " UNSIGNED,\n" + " BOOL,\n" + " FLOAT,\n" + " DOUBLE,\n" + " COMPLEX\n" + "};", + EightIndent); + // Not enums. verifyFormat("enum X f() {\n" " a();\n" Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -423,7 +423,7 @@ State.Stack.back().BreakBeforeParameter && Current.CanBreakBefore) return true; - if (State.Column <= NewLineColumn) + if (!State.Line->First->is(tok::kw_enum) && State.Column <= NewLineColumn) return false; if (Style.AlwaysBreakBeforeMultilineStrings &&
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -1929,6 +1929,24 @@ " TWO\n" "};\n" "int i;"); + + FormatStyle EightIndent = getLLVMStyle(); + EightIndent.IndentWidth = 8; + verifyFormat("enum {\n" + " VOID,\n" + " CHAR,\n" + " SHORT,\n" + " INT,\n" + " LONG,\n" + " SIGNED,\n" + " UNSIGNED,\n" + " BOOL,\n" + " FLOAT,\n" + " DOUBLE,\n" + " COMPLEX\n" + "};", + EightIndent); + // Not enums. verifyFormat("enum X f() {\n" " a();\n" Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -423,7 +423,7 @@ State.Stack.back().BreakBeforeParameter && Current.CanBreakBefore) return true; - if (State.Column <= NewLineColumn) + if (!State.Line->First->is(tok::kw_enum) && State.Column <= NewLineColumn) return false; if (Style.AlwaysBreakBeforeMultilineStrings &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits