]> granicus.if.org Git - clang/commitdiff
Parse record declarations with token pasted identifiers.
authorManuel Klimek <klimek@google.com>
Wed, 6 Feb 2013 15:57:54 +0000 (15:57 +0000)
committerManuel Klimek <klimek@google.com>
Wed, 6 Feb 2013 15:57:54 +0000 (15:57 +0000)
This is pretty common in macros:
 #define A(X, Y) class X##Y {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174512 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 19bca8d860ddc7d5ab68505ed29444e4153d450a..f79cc712f43279e197196b7cf997de8ce84ee64c 100644 (file)
@@ -650,9 +650,11 @@ void UnwrappedLineParser::parseRecord() {
     if (FormatTok.Tok.is(tok::l_paren)) {
       parseParens();
     }
-    // The actual identifier can be a nested name specifier.
+    // The actual identifier can be a nested name specifier, and in macros
+    // it is often token-pasted.
     while (FormatTok.Tok.is(tok::identifier) ||
-           FormatTok.Tok.is(tok::coloncolon))
+           FormatTok.Tok.is(tok::coloncolon) ||
+           FormatTok.Tok.is(tok::hashhash))
       nextToken();
 
     // Note that parsing away template declarations here leads to incorrectly
index cd3bf17df2d94661fc050d72beaa13af5e6bf568..fc95acca5278a4bda06a1608dc524e47720e5461 100644 (file)
@@ -1859,6 +1859,7 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
   verifyFormat("class MACRO(X) Z {\n} n;");
   verifyFormat("class __attribute__(X) Z {\n} n;");
   verifyFormat("class __declspec(X) Z {\n} n;");
+  verifyFormat("class A##B##C {\n} n;");
 
   // Redefinition from nested context:
   verifyFormat("class A::B::C {\n} n;");