aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2024-08-28 18:23:54 -0700
committerGitHub <noreply@github.com>2024-08-28 18:23:54 -0700
commit438ad9f2bf25575c474313de4ad85a5da6f69e4c (patch)
treede1b7997d18ba7307cfc4661d3b5dbabcce7ab02 /clang/lib/Format/ContinuationIndenter.cpp
parent8927576b8f6442bb6129bda597efee46176f8aec (diff)
downloadllvm-438ad9f2bf25575c474313de4ad85a5da6f69e4c.zip
llvm-438ad9f2bf25575c474313de4ad85a5da6f69e4c.tar.gz
llvm-438ad9f2bf25575c474313de4ad85a5da6f69e4c.tar.bz2
[clang-format] Revert "[clang-format][NFC] Delete TT_LambdaArrow (#70… (#105923)
…519)" This reverts commit e00d32afb9d33a1eca48e2b041c9688436706c5b and adds a test for lambda arrow SplitPenalty. Fixes #105480.
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 2422dee..5843571 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -894,10 +894,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
CurrentState.ContainsUnwrappedBuilder = true;
}
- if (Current.is(TT_TrailingReturnArrow) &&
- Style.Language == FormatStyle::LK_Java) {
+ if (Current.is(TT_LambdaArrow) && Style.Language == FormatStyle::LK_Java)
CurrentState.NoLineBreak = true;
- }
if (Current.isMemberAccess() && Previous.is(tok::r_paren) &&
(Previous.MatchingParen &&
(Previous.TotalLength - Previous.MatchingParen->TotalLength > 10))) {
@@ -1052,7 +1050,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
//
// is common and should be formatted like a free-standing function. The same
// goes for wrapping before the lambda return type arrow.
- if (Current.isNot(TT_TrailingReturnArrow) &&
+ if (Current.isNot(TT_LambdaArrow) &&
(!Style.isJavaScript() || Current.NestingLevel != 0 ||
!PreviousNonComment || PreviousNonComment->isNot(tok::equal) ||
!Current.isOneOf(Keywords.kw_async, Keywords.kw_function))) {
@@ -1312,7 +1310,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
}
return CurrentState.Indent;
}
- if (Current.is(TT_TrailingReturnArrow) &&
+ if (Current.is(TT_LambdaArrow) &&
Previous.isOneOf(tok::kw_noexcept, tok::kw_mutable, tok::kw_constexpr,
tok::kw_consteval, tok::kw_static, TT_AttributeSquare)) {
return ContinuationIndent;
@@ -1646,7 +1644,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
}
if (Current.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) && Newline)
CurrentState.NestedBlockIndent = State.Column + Current.ColumnWidth + 1;
- if (Current.isOneOf(TT_LambdaLSquare, TT_TrailingReturnArrow))
+ if (Current.isOneOf(TT_LambdaLSquare, TT_LambdaArrow))
CurrentState.LastSpace = State.Column;
if (Current.is(TT_RequiresExpression) &&
Style.RequiresExpressionIndentation == FormatStyle::REI_Keyword) {