Hi, I haven't been following the formatter patches (partly because it looks
like a big collection of different cases and I don't really have the time to
devote to understanding it) so this is maybe naive or has been done before, but
presumably formatting isn't that performance sensitive so is there scope for
(ab)using some of the C++ language to remove some of the redundancy from big
lists of what the token is not (not just in this patch but in the formatter in
general)? It'd make the code a bit more approachable...
Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -386,11 +386,31 @@
parseLabel();
return;
}
- // Recognize function-like macro usages without trailing semicolon in
- // declaration context.
+ // Recognize function-like macro usages without trailing semicolon.
if (FormatTok.Tok.is(tok::l_paren)) {
parseParens();
- if (Line->MustBeDeclaration && FormatTok.HasUnescapedNewline) {
+ if (FormatTok.HasUnescapedNewline && FormatTok.Tok.isNot(tok::semi)
&&
+ FormatTok.Tok.isNot(tok::l_brace) &&
+ FormatTok.Tok.isNot(tok::l_square) &&
+ FormatTok.Tok.isNot(tok::period) &&
+ FormatTok.Tok.isNot(tok::arrow) &&
+ FormatTok.Tok.isNot(tok::arrowstar) &&
+ FormatTok.Tok.isNot(tok::lessless) &&
+ FormatTok.Tok.isNot(tok::colon) &&
+ FormatTok.Tok.isNot(tok::plusplus) &&
+ FormatTok.Tok.isNot(tok::minusminus) &&
+ FormatTok.Tok.isNot(tok::equal) &&
+ FormatTok.Tok.isNot(tok::plusequal) &&
+ FormatTok.Tok.isNot(tok::minusequal) &&
+ FormatTok.Tok.isNot(tok::starequal) &&
+ FormatTok.Tok.isNot(tok::slashequal) &&
+ FormatTok.Tok.isNot(tok::percentequal) &&
+ FormatTok.Tok.isNot(tok::ampequal) &&
+ FormatTok.Tok.isNot(tok::pipeequal) &&
+ FormatTok.Tok.isNot(tok::caretequal) &&
+ FormatTok.Tok.isNot(tok::greatergreaterequal) &&
+ FormatTok.Tok.isNot(tok::lesslessequal) &&
+ FormatTok.Tok.isNot(tok::kw_try)) {
addUnwrappedLine();
return;
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits