Parse record declarations with token pasted identifiers.

This is pretty common in macros:
 #define A(X, Y) class X##Y {};

llvm-svn: 174512
This commit is contained in:
Manuel Klimek 2013-02-06 15:57:54 +00:00
parent 09aba10499
commit d265090cd6
2 changed files with 5 additions and 2 deletions

View 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

View 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;");