diff options
| author | Manuel Klimek <klimek@google.com> | 2013-01-21 10:17:14 +0000 |
|---|---|---|
| committer | Manuel Klimek <klimek@google.com> | 2013-01-21 10:17:14 +0000 |
| commit | 3c6b7c7d717ce183beb2478d43ddf2b557416a49 (patch) | |
| tree | 5a6d26b7bf0f6fc4d2cea1c6783fb1b6c434519e | |
| parent | c4352ec26ad150b3af0c8703161cb471bbafbf93 (diff) | |
| download | bcm5719-llvm-3c6b7c7d717ce183beb2478d43ddf2b557416a49.tar.gz bcm5719-llvm-3c6b7c7d717ce183beb2478d43ddf2b557416a49.zip | |
Allow for nested name specifiers in record declarations.
Now correctly formats:
class A::B {} n;
llvm-svn: 173019
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 3fd1ff9024e..dffc309a09e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -615,7 +615,9 @@ void UnwrappedLineParser::parseRecord() { 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)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1d3463ccfd2..3c929a3f532 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1519,13 +1519,17 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) { // 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" |

