@@ -821,6 +821,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
821
821
if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
822
822
!CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope () &&
823
823
Previous.isNot (TT_ObjCMethodExpr) && Previous.isNot (TT_RequiresClause) &&
824
+ Previous.isNot (TT_TableGenDAGArgOpener) &&
824
825
!(Current.MacroParent && Previous.MacroParent ) &&
825
826
(Current.isNot (TT_LineComment) ||
826
827
Previous.isOneOf (BK_BracedInit, TT_VerilogMultiLineListLParen))) {
@@ -1250,7 +1251,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
1250
1251
return CurrentState.Indent ;
1251
1252
}
1252
1253
if ((Current.isOneOf (tok::r_brace, tok::r_square) ||
1253
- (Current.is (tok::greater) && Style.isProto ())) &&
1254
+ (Current.is (tok::greater) && ( Style.isProto () || Style. isTableGen () ))) &&
1254
1255
State.Stack .size () > 1 ) {
1255
1256
if (Current.closesBlockOrBlockTypeList (Style))
1256
1257
return State.Stack [State.Stack .size () - 2 ].NestedBlockIndent ;
@@ -1278,6 +1279,12 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
1278
1279
Current.Next ->isOneOf (tok::semi, tok::kw_const, tok::l_brace))) {
1279
1280
return State.Stack [State.Stack .size () - 2 ].LastSpace ;
1280
1281
}
1282
+ // When DAGArg closer exists top of line, it should be aligned in the similar
1283
+ // way as function call above.
1284
+ if (Style.isTableGen () && Current.is (TT_TableGenDAGArgCloser) &&
1285
+ State.Stack .size () > 1 ) {
1286
+ return State.Stack [State.Stack .size () - 2 ].LastSpace ;
1287
+ }
1281
1288
if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent &&
1282
1289
(Current.is (tok::r_paren) ||
1283
1290
(Current.is (tok::r_brace) && Current.MatchingParen &&
@@ -1696,7 +1703,9 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
1696
1703
(!Previous || Previous->isNot (tok::kw_return) ||
1697
1704
(Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0 )) &&
1698
1705
(Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
1699
- PrecedenceLevel != prec::Comma || Current.NestingLevel == 0 )) {
1706
+ PrecedenceLevel != prec::Comma || Current.NestingLevel == 0 ) &&
1707
+ (!Style.isTableGen () ||
1708
+ (Previous && Previous->is (TT_TableGenDAGArgListComma)))) {
1700
1709
NewParenState.Indent = std::max (
1701
1710
std::max (State.Column , NewParenState.Indent ), CurrentState.LastSpace );
1702
1711
}
@@ -1942,6 +1951,7 @@ void ContinuationIndenter::moveStatePastScopeCloser(LineState &State) {
1942
1951
(Current.isOneOf (tok::r_paren, tok::r_square, TT_TemplateString) ||
1943
1952
(Current.is (tok::r_brace) && State.NextToken != State.Line ->First ) ||
1944
1953
State.NextToken ->is (TT_TemplateCloser) ||
1954
+ State.NextToken ->is (TT_TableGenListCloser) ||
1945
1955
(Current.is (tok::greater) && Current.is (TT_DictLiteral)))) {
1946
1956
State.Stack .pop_back ();
1947
1957
}
0 commit comments