[PATCH] D134853: [clang-format] Correctly annotate UDLs as OverloadedOperator

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 1 15:49:25 PDT 2022


owenpan added a comment.

In D134853#3822842 <https://reviews.llvm.org/D134853#3822842>, @rymiel wrote:

> Unless any reviewers have any other opinions, I would leave fixing those out of this patch and leave the tests "incomplete" for now?

+1.

> Also, UDLs that don't start with an underscore aren't considered a single "string_literal" token, instead becoming a string literal `""` and an identifier following it (where as those with an underscore become one token, such as `""_a`). I'm unsure if that's the expected case and if both tokens should just be considered part of the operator

The operator `""` and the identifier that follows should be two separate tokens regardless if the identifier starts with an underscore.



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1185
+                TT_BinaryOperator, TT_UnaryOperator, tok::comma, tok::star,
+                tok::arrow, tok::amp, tok::ampamp, tok::string_literal)) {
           CurrentToken->Previous->setType(TT_OverloadedOperator);
----------------
We should check for `""`, not just any `string_literal`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134853



More information about the cfe-commits mailing list