Fix operator<< recognition (PR19064).

llvm-svn: 203123
This commit is contained in:
Alexander Kornienko 2014-03-06 15:13:08 +00:00
parent 8cbf633715
commit 86b2dfdc3b
2 changed files with 9 additions and 2 deletions

View File

@ -174,7 +174,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
}
// Same as above, but for the first "<<" operator.
if (Current.is(tok::lessless) && State.Stack.back().BreakBeforeParameter &&
if (Current.is(tok::lessless) && Current.Type != TT_OverloadedOperator &&
State.Stack.back().BreakBeforeParameter &&
State.Stack.back().FirstLessLess == 0)
return true;
@ -515,7 +516,8 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
if (Current.Type == TT_InheritanceColon)
State.Stack.back().AvoidBinPacking = true;
if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess == 0)
if (Current.is(tok::lessless) && Current.Type != TT_OverloadedOperator &&
State.Stack.back().FirstLessLess == 0)
State.Stack.back().FirstLessLess = State.Column;
if (Current.Type == TT_ArraySubscriptLSquare &&
State.Stack.back().StartOfArraySubscripts == 0)

View File

@ -3077,6 +3077,11 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
"operator>(const SomeLoooooooooooooooooooooooooogType &other);");
verifyFormat("SomeLoooooooooooooooooooooooooogType\n"
"operator>>(const SomeLooooooooooooooooooooooooogType &other);");
verifyFormat("SomeLoooooooooooooooooooooooooogType\n"
"operator<<(const SomeLooooooooooooooooooooooooogType &other);");
verifyGoogleFormat(
"SomeLoooooooooooooooooooooooooooooogType operator>>(\n"
" const SomeLooooooooogType &a, const SomeLooooooooogType &b);");
verifyGoogleFormat(
"SomeLoooooooooooooooooooooooooooooogType operator<<(\n"
" const SomeLooooooooogType &a, const SomeLooooooooogType &b);");