[PATCH] D127873: [clang-format] Fix misplacement of `*` in declaration of pointer to struct

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 10:03:42 PDT 2022


owenpan added a comment.

In D127873#3600978 <https://reviews.llvm.org/D127873#3600978>, @jackhong12 wrote:

> Thanks. I am not sure which modification will be better, the patch I submitted or the following code.
>
>   FormatToken *BeforeLBraceToken = nullptr;
>   if (MatchingLBrace)
>     BeforeLBraceToken = MatchingLBrace->getPreviousNonComment();
>   
>   if (BeforeLBraceToken && BeforeLBraceToken->is(TT_TemplateCloser))
>     return TT_BinaryOperator;

How about the following?

  if (!MatchingLBrace)
    return TT_PointerOrReference;
  const FormatToken *BeforeLBrace = MatchingLBrace->getPreviousNonComment();
  if (!BeforeLBrace || BeforeLBrace->isNot(TT_TemplateCloser))
    return TT_PointerOrReference;
  return TT_BinaryOperator;


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127873/new/

https://reviews.llvm.org/D127873



More information about the cfe-commits mailing list