forked from OSchip/llvm-project
clang-format: Better support functions with elaborated enum return types.
Before, this wasn't formatted properly: enum ::C f() { return a; } llvm-svn: 240021
This commit is contained in:
parent
f90346f8f6
commit
47721ac75d
|
@ -1491,6 +1491,8 @@ void UnwrappedLineParser::parseEnum() {
|
|||
while (FormatTok->Tok.getIdentifierInfo() ||
|
||||
FormatTok->isOneOf(tok::colon, tok::coloncolon, tok::less,
|
||||
tok::greater, tok::comma, tok::question)) {
|
||||
if (FormatTok->is(tok::coloncolon))
|
||||
nextToken();
|
||||
nextToken();
|
||||
// We can have macros or attributes in between 'enum' and the enum name.
|
||||
if (FormatTok->is(tok::l_paren))
|
||||
|
|
|
@ -1996,7 +1996,6 @@ TEST_F(FormatTest, FormatsEnum) {
|
|||
verifyFormat("enum X E {} d;");
|
||||
verifyFormat("enum __attribute__((...)) E {} d;");
|
||||
verifyFormat("enum __declspec__((...)) E {} d;");
|
||||
verifyFormat("enum X f() {\n a();\n return 42;\n}");
|
||||
verifyFormat("enum {\n"
|
||||
" Bar = Foo<int, int>::value\n"
|
||||
"};",
|
||||
|
@ -2025,6 +2024,19 @@ TEST_F(FormatTest, FormatsEnum) {
|
|||
" TWO\n"
|
||||
"};\n"
|
||||
"int i;");
|
||||
// Not enums.
|
||||
verifyFormat("enum X f() {\n"
|
||||
" a();\n"
|
||||
" return 42;\n"
|
||||
"}");
|
||||
verifyFormat("enum ::X f() {\n"
|
||||
" a();\n"
|
||||
" return 42;\n"
|
||||
"}");
|
||||
verifyFormat("enum ns::X f() {\n"
|
||||
" a();\n"
|
||||
" return 42;\n"
|
||||
"}");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatsEnumsWithErrors) {
|
||||
|
|
Loading…
Reference in New Issue