diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 318bb259509..e7a50aa4329 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2517,7 +2517,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return true; if (Left.is(tok::l_brace) && Line.Level == 0 && (Line.startsWith(tok::kw_enum) || - Line.startsWith(tok::kw_export, tok::kw_enum))) + Line.startsWith(tok::kw_const, tok::kw_enum) || + Line.startsWith(tok::kw_export, tok::kw_enum) || + Line.startsWith(tok::kw_export, tok::kw_const, tok::kw_enum))) // JavaScript top-level enum key/value pairs are put on separate lines // instead of bin-packing. return true; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index d91df54f3da..54e2c8fbe95 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1425,6 +1425,14 @@ TEST_F(FormatTestJS, EnumDeclarations) { " B\n" "}\n" "var x = 1;"); + verifyFormat("const enum Foo {\n" + " A = 1,\n" + " B\n" + "}"); + verifyFormat("export const enum Foo {\n" + " A = 1,\n" + " B\n" + "}"); } TEST_F(FormatTestJS, MetadataAnnotations) { |