[PATCH] Again macros without trailing semicolons: don't care about declaration context.
Alexander Kornienko
alexfh at google.com
Tue Apr 9 09:19:34 PDT 2013
On Tue, Apr 9, 2013 at 5:47 PM, David Tweed <david.tweed at arm.com> wrote:
> 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...
>
We already have AnnotatedToken::isOneOf, and maybe I'll move it to
FormatToken some time later.
>
> 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
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
--
Alexander Kornienko | Software Engineer | alexfh at google.com | +49 151 221
77 957
Google Germany GmbH | Dienerstr. 12 | 80331 München
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130409/eea19185/attachment.html>
More information about the cfe-commits
mailing list