[cfe-commits] r173019 - in /cfe/trunk: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp
Manuel Klimek
klimek at google.com
Mon Jan 21 02:17:14 PST 2013
Author: klimek
Date: Mon Jan 21 04:17:14 2013
New Revision: 173019
URL: http://llvm.org/viewvc/llvm-project?rev=173019&view=rev
Log:
Allow for nested name specifiers in record declarations.
Now correctly formats:
class A::B {} n;
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=173019&r1=173018&r2=173019&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jan 21 04:17:14 2013
@@ -615,7 +615,9 @@
if (FormatTok.Tok.is(tok::l_paren)) {
parseParens();
}
- if (FormatTok.Tok.is(tok::identifier))
+ // The actual identifier can be a nested name specifier.
+ while (FormatTok.Tok.is(tok::identifier) ||
+ FormatTok.Tok.is(tok::coloncolon))
nextToken();
if (FormatTok.Tok.is(tok::colon)) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173019&r1=173018&r2=173019&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 21 04:17:14 2013
@@ -1519,13 +1519,17 @@
// Actual definitions...
verifyFormat("struct {} n;");
- verifyFormat("template <template <class T, class Y>, class Z > class X {} n;");
+ verifyFormat(
+ "template <template <class T, class Y>, class Z > class X {} n;");
verifyFormat("union Z {\n int n;\n} x;");
verifyFormat("class MACRO Z {} n;");
verifyFormat("class MACRO(X) Z {} n;");
verifyFormat("class __attribute__(X) Z {} n;");
verifyFormat("class __declspec(X) Z {} n;");
+ // Redefinition from nested context:
+ verifyFormat("class A::B::C {} n;");
+
// Elaborate types where incorrectly parsing the structural element would
// break the indent.
verifyFormat("if (true)\n"
More information about the cfe-commits
mailing list