]> granicus.if.org Git - clang/commitdiff
clang-format: Format typed enums with nested names.
authorDaniel Jasper <djasper@google.com>
Fri, 6 Sep 2013 21:32:35 +0000 (21:32 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 6 Sep 2013 21:32:35 +0000 (21:32 +0000)
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
unittests/Format/FormatTest.cpp

index 521df8f02852f7ad5925e0615ee8bd52dc9412b0..f70de5f6d88e981264c031a819e43b02befe0f4d 100644 (file)
@@ -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)) {
index ae35cccc4348b2b076ead378496946569bfbb920..79dbad79c67cb1f728974d35020c9bf80fc0f72c 100644 (file)
@@ -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) {