From: Manuel Klimek Date: Thu, 31 Jul 2014 07:19:30 +0000 (+0000) Subject: Fix parsing of classes where the class name is an absolute nested name specifier. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=785d3d6a038ad3d67fae953237fe7ba85ae7ccb7;p=clang Fix parsing of classes where the class name is an absolute nested name specifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214393 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 20dd573162..293fd3c8bd 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -1327,10 +1327,8 @@ void UnwrappedLineParser::parseEnum() { void UnwrappedLineParser::parseRecord() { nextToken(); - if (FormatTok->Tok.is(tok::identifier) || - FormatTok->Tok.is(tok::kw___attribute) || - FormatTok->Tok.is(tok::kw___declspec) || - FormatTok->Tok.is(tok::kw_alignas)) { + if (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::kw___attribute, + tok::kw___declspec, tok::kw_alignas)) { nextToken(); // We can have macros or attributes in between 'class' and the class name. if (FormatTok->Tok.is(tok::l_paren)) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 420129f1be..bebd8d67d4 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1846,6 +1846,7 @@ TEST_F(FormatTest, FormatsClasses) { verifyFormat("template \n" "struct Aaaaaaaaaaaaaaaaa\n" " : Aaaaaaaaaaaaaaaaa {};"); + verifyFormat("class ::A::B {};"); } TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {