[PATCH] D116920: [clang-format] clang-format eats space in front of attributes for operator delete
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 10 02:50:04 PST 2022
MyDeveloperDay 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);
----------------
curdeius wrote:
> 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?
I will check to see if we can use that..
To answer your second question, the existing code was this...
`!isOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case,tok::kw_delete)`
its the `kw_delete` here that breaks the previous code.
to cover this being a cast
`delete (A *)a;`
my change is to use more context by avoid `operator delete (A* a) a;` from being seen as a cast
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