From e27dc5d8ab967912b9a3d792ad32cad63981a974 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 6 Sep 2013 21:32:35 +0000 Subject: [PATCH] clang-format: Format typed enums with nested names. The explicit type specified for an enum can actually have a nested name specifier. This fixes llvm.org/PR17125. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190208 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 3 ++- unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 521df8f028..f70de5f6d8 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -1036,7 +1036,8 @@ void UnwrappedLineParser::parseEnum() { if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct)) nextToken(); - while (FormatTok->Tok.getIdentifierInfo() || FormatTok->Tok.is(tok::colon)) { + while (FormatTok->Tok.getIdentifierInfo() || + FormatTok->isOneOf(tok::colon, tok::coloncolon)) { nextToken(); // We can have macros or attributes in between 'enum' and the enum name. if (FormatTok->Tok.is(tok::l_paren)) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index ae35cccc43..79dbad79c6 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1591,6 +1591,10 @@ TEST_F(FormatTest, FormatsEnumTypes) { " A,\n" " B\n" "};"); + verifyFormat("enum X : std::uint32_t {\n" + " A,\n" + " B\n" + "};"); } TEST_F(FormatTest, FormatsBitfields) { -- 2.40.0