diff options
author | Daniel Jasper <djasper@google.com> | 2015-06-18 15:45:17 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-06-18 15:45:17 +0000 |
commit | 47721ac75d8b14dc09cbc6ee1906c1319610a4d1 (patch) | |
tree | 55b052d69a0414d669e5803f2a86468726f733fb /clang | |
parent | f90346f8f6ebd4ce4589ba070e4baaeede80988a (diff) | |
download | bcm5719-llvm-47721ac75d8b14dc09cbc6ee1906c1319610a4d1.tar.gz bcm5719-llvm-47721ac75d8b14dc09cbc6ee1906c1319610a4d1.zip |
clang-format: Better support functions with elaborated enum return types.
Before, this wasn't formatted properly:
enum ::C f() {
return a;
}
llvm-svn: 240021
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index aa46e7464cd..6846158fb3a 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -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)) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index ea5ff189da3..122a1a6c5f1 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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) { |