[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 06:04:54 PDT 2019


sammccall added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2090
         continue;
+      if (Next->isOneOf(tok::star, tok::arrow))
+        continue;
----------------
MyDeveloperDay wrote:
> sammccall wrote:
> > This seems like it's supposed to be handled by the token annotator, and the same cause will result in bugs in other places - why aren't these tokens being marked as TT_OverloadedOperator?
> > 
> > I'd guess the deeper fix is in the `kw_operator` case in consumeToken(). The way it's written looks suspect, though I'm not an expert on any of this.
> The * from *() is already labelled as a TT_PointerOrRefernce so can't also be marked as an Overloaded operator so use that in the loop.
Right, the fact that it's incorrectly labeled as a PointerOrReference is a bug, is it not possible to fix that instead of working around it here?

In the consumeToken loop, it seems the `*` in `operator *`  is labeled as PointerOrReference by logic that's trying to handle e.g. `StringRef::operator char*()`. However when the `*` is _immediately_ preceded by `operator`, it's always an overloaded operator name rather than a pointer, I think?


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

https://reviews.llvm.org/D69573





More information about the cfe-commits mailing list