r190208 - clang-format: Format typed enums with nested names.
Daniel Jasper
djasper at google.com
Fri Sep 6 14:32:35 PDT 2013
Author: djasper
Date: Fri Sep 6 16:32:35 2013
New Revision: 190208
URL: http://llvm.org/viewvc/llvm-project?rev=190208&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=190208&r1=190207&r2=190208&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Sep 6 16:32:35 2013
@@ -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)) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=190208&r1=190207&r2=190208&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Sep 6 16:32:35 2013
@@ -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) {
More information about the cfe-commits
mailing list