[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 13 21:52:46 PST 2020


ChuanqiXu added a comment.

In D91245#2437741 <https://reviews.llvm.org/D91245#2437741>, @Quuxplusone wrote:

> Peanut gallery says: It seems to me that your root problem here is that `co_yield` is not being recognized by the parser as a keyword, and so you're seeing e.g. `co_yield* p;` the same way you'd see `CoYield* p;`.
> But in that case, you should also be seeing `co_yield -1;` formatted as `co_yield - 1;` the same way you'd see `CoYield - 1;`.
> Is it possible that you're not using the right (C++20) language mode? (OTOH, see D69144 <https://reviews.llvm.org/D69144>, D69180 <https://reviews.llvm.org/D69180>, which //also// didn't concern themselves with language modes. I don't understand why not.)
>
> Could you please re-upload the diff with context (i.e. `git show -U999`)?

Yes, it looks like that `co_yield` is not being recognized as keywords. I use the `Auto` for Standard attribute in `.clang-format` config file. And `co*` would be recognized as keywords. From my point of view, I first find that the keyword `return`  was processed specifically in the line 1962 in `TokenAnnotator.cpp` which recognize `return` as Unary Operator. So I choose to recognize `co*` keywords as Unary Operators to solve the format problem.


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

https://reviews.llvm.org/D91245



More information about the cfe-commits mailing list