r174512 - Parse record declarations with token pasted identifiers.
Manuel Klimek
klimek at google.com
Wed Feb 6 07:57:55 PST 2013
Author: klimek
Date: Wed Feb 6 09:57:54 2013
New Revision: 174512
URL: http://llvm.org/viewvc/llvm-project?rev=174512&view=rev
Log:
Parse record declarations with token pasted identifiers.
This is pretty common in macros:
#define A(X, Y) class X##Y {};
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=174512&r1=174511&r2=174512&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Feb 6 09:57:54 2013
@@ -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
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=174512&r1=174511&r2=174512&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Feb 6 09:57:54 2013
@@ -1859,6 +1859,7 @@ TEST_F(FormatTest, UnderstandContextOfRe
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;");
More information about the cfe-commits
mailing list