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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 11 08:14:28 PDT 2021


aaron.ballman added a comment.

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`

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.



================
Comment at: clang/lib/Parse/ParseDecl.cpp:5830-5832
+        constexpr int Caret = 3;
+        constexpr int Empty = 2;
+        constexpr int BlockPointers = 2;
----------------
We typically either use comments for one-off uses, or we hoist this sort of thing to an enumeration associated with the diagnostic if we think the diagnostic will be used in enough places to warrant it. I think we should probably stick to comments for this one (e.g., `Diag(Loc, diag::whatever) << /*frobble*/1;`, but if you think a hoisted enum is a better approach I won't argue it.

(Same comment applies elsewhere in the patch.)


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