[PATCH] D77682: [clang-format] Always break line after enum opening brace
Omar Sandoval via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 12:11:01 PDT 2020
osandov updated this revision to Diff 256352.
osandov edited the summary of this revision.
osandov added a comment.
Update summary and test case to better reflect the issue
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 &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77682.256352.patch
Type: text/x-patch
Size: 1428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200409/737e00f5/attachment.bin>
More information about the cfe-commits
mailing list