[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 29 13:52:50 PDT 2019
MyDeveloperDay marked 4 inline comments as done.
MyDeveloperDay 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))) {
----------------
sammccall wrote:
> 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`
rearranged the logic as suggested, unfortunately we can't use TT_LoverloadOperator at this point because its not yet been annotated (so ! has TT_Unknown still)
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2090
continue;
+ if (Next->isOneOf(tok::star, tok::arrow))
+ continue;
----------------
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.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69573/new/
https://reviews.llvm.org/D69573
More information about the cfe-commits
mailing list