diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-04-08 22:16:06 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-04-08 22:16:06 +0000 |
commit | 3d713a72a01bf1d270d00040a3fb195121012c61 (patch) | |
tree | 336a172557e6566b6de48ac326899f0a0550fff6 /lib | |
parent | 0db9d2066318f3721a45954e23b26ac8ef0723bb (diff) |
Recognize function-like macro usages without semicolon in declaration context.
Summary:
Preserve line breaks after function-like macro usages without
semicolon, e.g.:
QQQ(xxx)
class X {
};
Reviewers: djasper, klimek
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D638
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 89a391bd19..12b7f7866f 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -71,7 +71,7 @@ public: } private: - bool eof() { return Token.NewlinesBefore > 0 && Token.HasUnescapedNewline; } + bool eof() { return Token.HasUnescapedNewline; } FormatToken createEOF() { FormatToken FormatTok; @@ -262,7 +262,6 @@ void UnwrappedLineParser::parsePPUnknown() { void UnwrappedLineParser::parseStructuralElement() { assert(!FormatTok.Tok.is(tok::l_brace)); - int TokenNumber = 0; switch (FormatTok.Tok.getKind()) { case tok::at: nextToken(); @@ -297,7 +296,6 @@ void UnwrappedLineParser::parseStructuralElement() { return; case tok::kw_inline: nextToken(); - TokenNumber++; if (FormatTok.Tok.is(tok::kw_namespace)) { parseNamespace(); return; @@ -347,7 +345,6 @@ void UnwrappedLineParser::parseStructuralElement() { break; } do { - ++TokenNumber; switch (FormatTok.Tok.getKind()) { case tok::at: nextToken(); @@ -384,9 +381,20 @@ void UnwrappedLineParser::parseStructuralElement() { return; case tok::identifier: nextToken(); - if (TokenNumber == 1 && FormatTok.Tok.is(tok::colon)) { - parseLabel(); - return; + if (Line->Tokens.size() == 1) { + if (FormatTok.Tok.is(tok::colon)) { + parseLabel(); + return; + } + // Recognize function-like macro usages without trailing semicolon in + // declaration context. + if (FormatTok.Tok.is(tok::l_paren)) { + parseParens(); + if (Line->MustBeDeclaration && FormatTok.HasUnescapedNewline) { + addUnwrappedLine(); + return; + } + } } break; case tok::equal: @@ -820,8 +828,7 @@ void UnwrappedLineParser::readToken() { do { FormatTok = Tokens->getNextToken(); while (!Line->InPPDirective && FormatTok.Tok.is(tok::hash) && - ((FormatTok.NewlinesBefore > 0 && FormatTok.HasUnescapedNewline) || - FormatTok.IsFirst)) { + (FormatTok.HasUnescapedNewline || FormatTok.IsFirst)) { // If there is an unfinished unwrapped line, we flush the preprocessor // directives only after that unwrapped line was finished later. bool SwitchToPreprocessorLines = |