[PATCH] D77682: [clang-format] Always break line after enum opening brace
Omar Sandoval via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 11:25:43 PDT 2020
osandov added a comment.
The style guide I'm following (the Linux kernel style) wants `AfterEnum: false`. A cursory search suggests that people treat this trailing comma behavior as a feature (https://stackoverflow.com/questions/23072223/clang-format-style-options-for-enums). However, I think this is separate from my issue. Consider the following example which doesn't have a trailing comma and doesn't fit on one line:
$ cat enum.cpp
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 };
The current code formats this very strangely:
$ clang-format -style="{BasedOnStyle: llvm, IndentWidth: 8}" enum.cpp
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 };
With this change, I get what I expect:
$ ./bin/clang-format -style="{BasedOnStyle: llvm, IndentWidth: 8}" enum.cpp
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
};
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77682/new/
https://reviews.llvm.org/D77682
More information about the cfe-commits
mailing list