[PATCH] D116920: [clang-format] clang-format eats space in front of attributes for operator delete

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 10 02:21:13 PST 2022


curdeius added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1729
     } else if (Current.is(tok::r_paren)) {
       if (rParenEndsCast(Current))
         Current.setType(TT_CastRParen);
----------------
The current solution looks a bit like a hack to me.
Unless I'm mistaken, casts can appear only in expressions, but not in declarations (except for inside `decltype` stuff in templates or concepts, but these are still expressions at this level).
Given that `void operator delete...` is not an expression but a declaration, we shouldn't check `rParenEndsCast` in this case at all, no?
So, would it be possible to check here for e.g. `Line.MightBeFunctionDecl` or something like this to avoid it?

Also, how is it that you don't need to special-case `new` operator?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116920



More information about the cfe-commits mailing list