State.ParenLevel = 0;
State.StartOfStringLiteral = 0;
State.StartOfLineLevel = State.ParenLevel;
- State.LowestLevelOnLine = State.ParenLevel;
+ State.LowestCallLevel = State.ParenLevel;
State.IgnoreStackForComparison = false;
// The first token has already been indented and thus consumed.
/// \brief The \c ParenLevel at the start of this line.
unsigned StartOfLineLevel;
- /// \brief The lowest \c ParenLevel on the current line.
- unsigned LowestLevelOnLine;
+ /// \brief The lowest \c ParenLevel of "." or "->" on the current line.
+ unsigned LowestCallLevel;
/// \brief The start column of the string literal, if we're in a string
/// literal sequence, 0 otherwise.
return ParenLevel < Other.ParenLevel;
if (StartOfLineLevel != Other.StartOfLineLevel)
return StartOfLineLevel < Other.StartOfLineLevel;
- if (LowestLevelOnLine != Other.LowestLevelOnLine)
- return LowestLevelOnLine < Other.LowestLevelOnLine;
+ if (LowestCallLevel != Other.LowestCallLevel)
+ return LowestCallLevel < Other.LowestCallLevel;
if (StartOfStringLiteral != Other.StartOfStringLiteral)
return StartOfStringLiteral < Other.StartOfStringLiteral;
if (IgnoreStackForComparison || Other.IgnoreStackForComparison)
Current.Type != TT_DesignatedInitializerPeriod)
State.Stack.back().LastSpace += Current.TokenLength;
State.StartOfLineLevel = State.ParenLevel;
- State.LowestLevelOnLine = State.ParenLevel;
+ State.LowestCallLevel = State.ParenLevel;
// Any break on this level means that the parent level has been broken
// and we need to avoid bin packing there.
State.Stack.back().FirstLessLess = State.Column;
if (Current.is(tok::question))
State.Stack.back().QuestionColumn = State.Column;
- if (Current.isOneOf(tok::period, tok::arrow) &&
- Line.Type == LT_BuilderTypeCall && State.ParenLevel == 0)
- State.Stack.back().StartOfFunctionCall =
- Current.LastInChainOfCalls ? 0 : State.Column + Current.TokenLength;
+ if (Current.isOneOf(tok::period, tok::arrow)) {
+ State.LowestCallLevel = std::min(State.LowestCallLevel, State.ParenLevel);
+ if (Line.Type == LT_BuilderTypeCall && State.ParenLevel == 0)
+ State.Stack.back().StartOfFunctionCall =
+ Current.LastInChainOfCalls ? 0 : State.Column + Current.TokenLength;
+ }
if (Current.Type == TT_CtorInitializerColon) {
// Indent 2 from the column, so:
// SomeClass::SomeClass()
State.Stack.pop_back();
--State.ParenLevel;
}
- State.LowestLevelOnLine =
- std::min(State.LowestLevelOnLine, State.ParenLevel);
// Remove scopes created by fake parenthesis.
for (unsigned i = 0, e = Current.FakeRParens; i != e; ++i) {
// SomeParameter, OtherParameter).DoSomething(
// ...
// As they hide "DoSomething" and are generally bad for readability.
- if (Previous.opensScope() &&
- State.LowestLevelOnLine < State.StartOfLineLevel)
+ if (Previous.opensScope() && State.LowestCallLevel < State.StartOfLineLevel)
return false;
return !State.Stack.back().NoLineBreak;
}