[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens in declarations

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 12 22:40:00 PDT 2021


cjdb added a comment.

In D107292#2939521 <https://reviews.llvm.org/D107292#2939521>, @aaron.ballman wrote:

> In D107292#2923261 <https://reviews.llvm.org/D107292#2923261>, @cjdb wrote:
>
>> Patch 2: expressions
>>
>> xor {}
>> bitand x // warning will suggest std::addressof in C++ land
>> and label
>
> An additional expression to cover, not that I think anyone would be this awful by accident, is: `foo->compl Foo(); // Pseudo-destructor call`

Nice catch!

> One question I have about both declarations and expressions are whether we have an appetite to diagnose overloaded operators or not. Personally, I think it'd be reasonable to diagnose something like `foo->operator bitand();` or `operator not_eq(A, B);` as expressions, but not reasonable to diagnose the declaration of the overloaded operators using alternative tokens.

I agree that `bool operator and(T, T);` shouldn't be diagnosed on (and this patch's clang-tidy sibling will one day also diagnose that, but it's way off).

I think that `foo->operator bitand()` and `operator not_eq(expr1, expr2)` should only diagnose if `foo->operator&()` and `operator!=(expr1, expr2)` are diagnosed, //and// I think that should be a separate warning (I'm not saying that's a good or bad thing to do yet: let me sleep on that). I might be misunderstanding your intention though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292



More information about the cfe-commits mailing list