summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-05 10:48:04 +0000
committerDaniel Jasper <djasper@google.com>2014-11-05 10:48:04 +0000
commit680b09ba8825311dc0fad69ed166a21e3f83bcbe (patch)
tree9bc01e3b874ddf2bcd236eced5b664982a3f31c5 /clang/lib/Format
parent70a3841a8fb0e4a2360cec3496c2eb984cdccc14 (diff)
downloadbcm5719-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.cpp17
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;
}
OpenPOWER on IntegriCloud