]> granicus.if.org Git - clang/commitdiff
Fix parsing of classes where the class name is an absolute nested name specifier.
authorManuel Klimek <klimek@google.com>
Thu, 31 Jul 2014 07:19:30 +0000 (07:19 +0000)
committerManuel Klimek <klimek@google.com>
Thu, 31 Jul 2014 07:19:30 +0000 (07:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214393 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index 20dd573162ccc39d5e21feee0bfb8da93340061b..293fd3c8bd1f81bed4c7f0247fe182cb95cafbb0 100644 (file)
@@ -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)) {
index 420129f1be28c1dc822b3ef0a8ced61f4d861b22..bebd8d67d4912b722ea62beb613e88639281c018 100644 (file)
@@ -1846,6 +1846,7 @@ TEST_F(FormatTest, FormatsClasses) {
   verifyFormat("template <class R, class C>\n"
                "struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const>\n"
                "    : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};");
+  verifyFormat("class ::A::B {};");
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {