diff options
author | Daniel Jasper <djasper@google.com> | 2014-11-05 10:48:04 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-11-05 10:48:04 +0000 |
commit | 680b09ba8825311dc0fad69ed166a21e3f83bcbe (patch) | |
tree | 9bc01e3b874ddf2bcd236eced5b664982a3f31c5 /clang/lib/Format | |
parent | 70a3841a8fb0e4a2360cec3496c2eb984cdccc14 (diff) | |
download | bcm5719-llvm-680b09ba8825311dc0fad69ed166a21e3f83bcbe.tar.gz bcm5719-llvm-680b09ba8825311dc0fad69ed166a21e3f83bcbe.zip |
clang-format: Improve free-standing macro detection.
Before:
SOME_WEIRD_LOG_MACRO
<< "Something long enough to cause a line break";
After:
SOME_WEIRD_LOG_MACRO
<< "Something long enough to cause a line break";
llvm-svn: 221338
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 0b37acbebf9..10b4aeaca33 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -812,17 +812,14 @@ void UnwrappedLineParser::parseStructuralElement() { parseLabel(); return; } - // Recognize function-like macro usages without trailing semicolon. - if (FormatTok->Tok.is(tok::l_paren)) { + // Recognize function-like macro usages without trailing semicolon as + // well as free-standing macrose like Q_OBJECT. + bool FunctionLike = FormatTok->is(tok::l_paren); + if (FunctionLike) parseParens(); - if (FormatTok->NewlinesBefore > 0 && - tokenCanStartNewLine(FormatTok->Tok) && Text == Text.upper()) { - addUnwrappedLine(); - return; - } - } else if (FormatTok->HasUnescapedNewline && Text.size() >= 5 && - Text == Text.upper()) { - // Recognize free-standing macros like Q_OBJECT. + if (FormatTok->NewlinesBefore > 0 && + (Text.size() >= 5 || FunctionLike) && + tokenCanStartNewLine(FormatTok->Tok) && Text == Text.upper()) { addUnwrappedLine(); return; } |