[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
Tue Oct 29 11:33:08 PDT 2019


sammccall added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1347
       Contexts.back().CanBeExpression = false;
-    } else if (Current.isOneOf(tok::semi, tok::exclaim)) {
+    } else if (Current.isOneOf(tok::semi, tok::exclaim) &&
+               !(Current.Previous && Current.Previous->is(tok::kw_operator))) {
----------------
This seems clearer as `is semi || (is exclaim && !previous is operator)`, as `operator;` isn't relevant here.
`&& !Current.is(TT_OverloadedOperator) would be even better of course`


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2090
         continue;
+      if (Next->isOneOf(tok::star, tok::arrow))
+        continue;
----------------
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.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69573





More information about the cfe-commits mailing list