Before this change enums were formatted incorrectly for the Microsoft style.
[C++ Example]
enum { one, two } three, four;
[Incorrectly Formatted]
enum { one, two } three, four;
[Correct Format with Patch]
enum { one, two } three, four;
Differential D78982
[clang-format] Fix Microsoft style for enums asmith on Apr 27 2020, 9:00 PM. Authored by
Details Before this change enums were formatted incorrectly for the Microsoft style. [C++ Example] enum { one, two } three, four; [Incorrectly Formatted] enum { one, two } three, four; [Correct Format with Patch] enum { one, two } three, four;
Diff Detail Event TimelineComment Actions Fix line breaks like this: enum { a=1, b=2, c=3 which becomes: enum a=1, b=2, c=3 } myEnum; Comment Actions Before looking into the merit of the change, it needs a couple of things
Comment Actions So it doesn't overcome the trailing "," issue. (which is sometimes used to put enums on multiple lines) - (NOTE: maybe it shouldn't) --- Language: Cpp BasedOnStyle: LLVM AllowEnumsOnASingleLine: true enum { B, C, D, } A, B; vs enum { B, C, D } A, B; Comment Actions I think the name should be AllowShortEnumsOnASingleLine As once the enum goes over a certain width it will revert to as it was before. enum { EOF, VOID, CHAR, SHORT, DOT, NUMBER, IDENTIFIER } A; vs enum { EOF, VOID, CHAR, SHORT, INT, LONG, SIGNED, UNSIGNED, BOOL, FLOAT, DOUBLE, COMPLEX, CONST, RESTRICT, VOLATILE, ATOMIC, STRUCT, UNION, ENUM, LPAREN, RPAREN, LBRACKET, RBRACKET, ASTERISK, DOT, NUMBER, IDENTIFIER } A;
Comment Actions Is there an easy way to check the test is working? 'ninja check-clang-format' passes but would like to verify.
Comment Actions The is done unless there are other comments.
Comment Actions see D79095: [clang-format] NFC Correct clang-format headers file so documentation can be once again autogenerated this should be handled separately.
Comment Actions You will need to rebase as the non related rst changes have been handled by D79095: [clang-format] NFC Correct clang-format headers file so documentation can be once again autogenerated Comment Actions @asmith I'm seeing MSVC warnings from this patch: E:\llvm\llvm-project\clang\lib\Format\UnwrappedLineParser.cpp(1475): warning C4305: 'argument': truncation from 'clang::tok::TokenKind' to 'bool' Comment Actions That's caused by the changed signature of parseBracedList and this change hasn't been taken into account at the above mentioned locations: - bool parseBracedList(bool ContinueOnSemicolons = false, + bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false, tok::TokenKind ClosingBraceKind = tok::r_brace); BTW, it's a bit strange that a new parameter had been added in the middle of parameter list. |
You'll need to fix up the C# tests
I think that is ok as most of the documentation seems to show them not on a single line
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum