[PATCH] D11177: clang-format: Fix return type breaking with operator overload functions
Daniel Jasper
djasper at google.com
Tue Jul 14 00:39:58 PDT 2015
djasper added inline comments.
================
Comment at: lib/Format/TokenAnnotator.cpp:509
@@ +508,3 @@
+ Tok->Previous->MatchingParen->Previous &&
+ Tok->Previous->MatchingParen->Previous->is(tok::kw_operator)) {
+ Tok->Previous->MatchingParen->Type = TT_OverloadedOperator;
----------------
Why is this last check important? To not mark operator()()()? Is that important?
================
Comment at: lib/Format/TokenAnnotator.cpp:1478
@@ -1470,1 +1477,3 @@
+ return false;
+ while (Next && !Next->is(TT_OverloadedOperatorLParen))
Next = Next->Next;
----------------
What kinds of tokens do you expect to consume here? Would it be better to be more strict, i.e. consume exactly an operator, "new", "delete", "()" and such?
================
Comment at: lib/Format/TokenAnnotator.cpp:1492
@@ +1491,3 @@
+ Next = Next->Next;
+ while (Next && !Next->is(TT_OverloadedOperatorLParen))
+ Next = Next->Next;
----------------
This is very similar to the above. What are the exact differences (maybe add a comment)? Could we factor some of this out into a local function or a lambda?
================
Comment at: lib/Format/TokenAnnotator.cpp:1495
@@ +1494,3 @@
+ break;
+ } else if (!Next->is(tok::identifier)) {
+ return false;
----------------
According to LLVM coding standards, no "else" after "return", "break" or "continue".
================
Comment at: lib/Format/TokenAnnotator.cpp:2187
@@ -2161,1 +2186,3 @@
return true;
+ if (Right.is(tok::kw_operator))
+ return !Left.is(tok::coloncolon);
----------------
I think this is incorrect as we currently break after the coloncolon if a nested name specifier has to be split, e.g.:
void AssumeThisIsAVeryLongTypeOrSetASmallColumnLimit::
operator+() {
}
http://reviews.llvm.org/D11177
More information about the cfe-commits
mailing list