[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 17 04:25:54 PST 2020


krasimir marked 3 inline comments as done.
krasimir added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2722
+    FormatToken *Before = Left.getPreviousNonComment();
+    while (Before && Before->isOneOf(tok::kw_const, tok::kw_volatile)) {
+      Before = Before->getPreviousNonComment();
----------------
mprobst wrote:
> how many const and volatile may be there, and is their order fixed?
> 
> We also have the `endsSequence` helper on FormatToken that might express the concept better (`Left.endsSequence(tok::kw_const, tok::kw_volatile) || ...`). YMMV, with the tokens being optional that might lead to too many alternates to check for.
Thank you! I think const and volatile can only appear once, and not both at the same time.
There are 3 cases to check for with `endsSequence` which is ok, and it's less code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911





More information about the cfe-commits mailing list