Lines Matching full:changes
55 Changes.push_back(Change(Tok, /*CreateReplacement=*/true, Tok.WhitespaceRange, in replaceWhitespace()
65 Changes.push_back(Change(Tok, /*CreateReplacement=*/false, in addUntouchableToken()
90 Changes.push_back( in replaceWhitespaceInToken()
99 if (Changes.empty()) in generateReplacements()
102 llvm::sort(Changes, Change::IsBeforeInFile(SourceMgr)); in generateReplacements()
118 Changes[0].PreviousEndOfTokenColumn = 0; in calculateLineBreakInformation()
119 Change *LastOutsideTokenChange = &Changes[0]; in calculateLineBreakInformation()
120 for (unsigned i = 1, e = Changes.size(); i != e; ++i) { in calculateLineBreakInformation()
122 Changes[i].OriginalWhitespaceRange.getBegin(); in calculateLineBreakInformation()
124 Changes[i - 1].OriginalWhitespaceRange.getEnd(); in calculateLineBreakInformation()
136 // Usually consecutive changes would occur in consecutive tokens. This is in calculateLineBreakInformation()
147 // and 3. So the two consecutive whitespace changes just before '// line 2' in calculateLineBreakInformation()
154 // For this reason, if the text between consecutive changes spans multiple in calculateLineBreakInformation()
159 Changes[i - 1].TokenLength = OriginalWhitespaceStartOffset - in calculateLineBreakInformation()
161 Changes[i].PreviousLinePostfix.size() + in calculateLineBreakInformation()
162 Changes[i - 1].CurrentLinePrefix.size(); in calculateLineBreakInformation()
164 Changes[i - 1].TokenLength = in calculateLineBreakInformation()
165 NewlinePos + Changes[i - 1].CurrentLinePrefix.size(); in calculateLineBreakInformation()
168 // If there are multiple changes in this token, sum up all the changes until in calculateLineBreakInformation()
170 if (Changes[i - 1].IsInsideToken && Changes[i - 1].NewlinesBefore == 0) { in calculateLineBreakInformation()
172 Changes[i - 1].TokenLength + Changes[i - 1].Spaces; in calculateLineBreakInformation()
174 LastOutsideTokenChange = &Changes[i - 1]; in calculateLineBreakInformation()
177 Changes[i].PreviousEndOfTokenColumn = in calculateLineBreakInformation()
178 Changes[i - 1].StartOfTokenColumn + Changes[i - 1].TokenLength; in calculateLineBreakInformation()
180 Changes[i - 1].IsTrailingComment = in calculateLineBreakInformation()
181 (Changes[i].NewlinesBefore > 0 || Changes[i].Tok->is(tok::eof) || in calculateLineBreakInformation()
182 (Changes[i].IsInsideToken && Changes[i].Tok->is(tok::comment))) && in calculateLineBreakInformation()
183 Changes[i - 1].Tok->is(tok::comment) && in calculateLineBreakInformation()
185 // BreakableLineCommentSection does comment reflow changes and here is in calculateLineBreakInformation()
192 // That amounts to 2 changes by BreakableLineCommentSection: in calculateLineBreakInformation()
200 // So in the end we have two changes like this: in calculateLineBreakInformation()
218 Changes.back().TokenLength = 0; in calculateLineBreakInformation()
219 Changes.back().IsTrailingComment = Changes.back().Tok->is(tok::comment); in calculateLineBreakInformation()
222 for (auto &Change : Changes) { in calculateLineBreakInformation()
223 // Reset the IsTrailingComment flag for changes inside of trailing comments in calculateLineBreakInformation()
249 for (auto &Change : Changes) { in calculateLineBreakInformation()
277 SmallVector<WhitespaceManager::Change, 16> &Changes) { in AlignTokenSequence() argument
305 Changes[i].indentAndNestingLevel() < in AlignTokenSequence()
306 Changes[ScopeStack.back()].indentAndNestingLevel()) { in AlignTokenSequence()
314 Changes[PreviousNonComment].Tok->is(tok::comment)) { in AlignTokenSequence()
317 if (i != Start && Changes[i].indentAndNestingLevel() > in AlignTokenSequence()
318 Changes[PreviousNonComment].indentAndNestingLevel()) { in AlignTokenSequence()
324 Changes[i].Tok->is(tok::string_literal) && in AlignTokenSequence()
325 Changes[i - 1].Tok->is(tok::string_literal); in AlignTokenSequence()
328 if (Changes[i].NewlinesBefore > 0 && !SkipMatchCheck) { in AlignTokenSequence()
334 // spaces it has to be shifted, so the rest of the changes on the line are in AlignTokenSequence()
336 if (!FoundMatchOnLine && !SkipMatchCheck && Matches(Changes[i])) { in AlignTokenSequence()
338 Shift = Column - (RightJustify ? Changes[i].TokenLength : 0) - in AlignTokenSequence()
339 Changes[i].StartOfTokenColumn; in AlignTokenSequence()
340 Changes[i].Spaces += Shift; in AlignTokenSequence()
343 if (Changes[i].NewlinesBefore == 0) { in AlignTokenSequence()
344 Changes[i].Spaces = in AlignTokenSequence()
345 std::max(Changes[i].Spaces, in AlignTokenSequence()
346 static_cast<int>(Changes[i].Tok->SpacesRequiredBefore)); in AlignTokenSequence()
352 if (InsideNestedScope && Changes[i].NewlinesBefore > 0) { in AlignTokenSequence()
356 if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName)) in AlignTokenSequence()
360 if (Changes[ScopeStart - 1].Tok->is(TT_LambdaLBrace)) in AlignTokenSequence()
365 Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName)) { in AlignTokenSequence()
371 Changes[ScopeStart - 2].Tok->is(tok::identifier) && in AlignTokenSequence()
372 Changes[ScopeStart - 1].Tok->is(tok::l_paren) && in AlignTokenSequence()
373 Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) { in AlignTokenSequence()
374 if (Changes[i].Tok->MatchingParen && in AlignTokenSequence()
375 Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace)) { in AlignTokenSequence()
378 if (Changes[ScopeStart].NewlinesBefore > 0) in AlignTokenSequence()
380 if (Changes[i].Tok->is(tok::l_brace) && in AlignTokenSequence()
381 Changes[i].Tok->is(BK_BracedInit)) { in AlignTokenSequence()
388 if (Changes[i].Tok->is(TT_ConditionalExpr)) in AlignTokenSequence()
392 if (Changes[i].Tok->is(TT_DesignatedInitializerPeriod)) in AlignTokenSequence()
396 if (Changes[i].Tok->Previous && in AlignTokenSequence()
397 Changes[i].Tok->Previous->is(TT_ConditionalExpr)) { in AlignTokenSequence()
403 Changes[ScopeStart - 2].Tok->is(tok::identifier) && in AlignTokenSequence()
404 Changes[ScopeStart - 1].Tok->is(tok::l_brace) && in AlignTokenSequence()
405 Changes[i].Tok->is(tok::l_brace) && in AlignTokenSequence()
406 Changes[i].Tok->is(BK_BracedInit)) { in AlignTokenSequence()
412 Changes[ScopeStart - 2].Tok->isNot(tok::identifier) && in AlignTokenSequence()
413 Changes[ScopeStart - 1].Tok->is(tok::l_brace) && in AlignTokenSequence()
414 Changes[i].Tok->isNot(tok::r_brace)) { in AlignTokenSequence()
418 Changes[OuterScopeStart - 1].Tok->is(TT_LambdaLBrace)) { in AlignTokenSequence()
422 if (Changes[ScopeStart].NewlinesBefore > 0) in AlignTokenSequence()
431 Changes[i].Spaces += Shift; in AlignTokenSequence()
435 Changes[i].Spaces += Shift; in AlignTokenSequence()
438 assert(Shift >= 0 || Changes[i].NewlinesBefore > 0 || in AlignTokenSequence()
439 Changes[i].Spaces >= in AlignTokenSequence()
440 static_cast<int>(Changes[i].Tok->SpacesRequiredBefore) || in AlignTokenSequence()
441 Changes[i].Tok->is(tok::eof)); in AlignTokenSequence()
443 Changes[i].StartOfTokenColumn += Shift; in AlignTokenSequence()
444 if (i + 1 != Changes.size()) in AlignTokenSequence()
445 Changes[i + 1].PreviousEndOfTokenColumn += Shift; in AlignTokenSequence()
449 Changes[i].Spaces != 0) { in AlignTokenSequence()
452 Changes[Previous].Tok->getType() == TT_PointerOrReference; in AlignTokenSequence()
454 Changes[Previous + 1].Spaces -= Shift; in AlignTokenSequence()
455 Changes[Previous].Spaces += Shift; in AlignTokenSequence()
456 Changes[Previous].StartOfTokenColumn += Shift; in AlignTokenSequence()
462 // Walk through a subset of the changes, starting at StartAt, and find
469 // exhausted all items inside Changes, or because we hit a scope level higher
472 // equal to the initial level, which is the level of Changes[StartAt].
495 SmallVector<WhitespaceManager::Change, 16> &Changes, in AlignTokens() argument
521 auto IndentAndNestingLevel = StartAt < Changes.size()
522 ? Changes[StartAt].indentAndNestingLevel()
555 Changes); in __anone58695710202()
565 for (unsigned e = Changes.size(); i != e; ++i) {
566 if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel) {
577 Changes[i].indentAndNestingLevel(); // new baseline
580 if (Changes[i].NewlinesBefore != 0) {
586 (Changes[i].NewlinesBefore > 1) && !ACS.AcrossEmptyLines;
598 if (i == 0 || !Changes[i].Tok->is(tok::string_literal) ||
599 !Changes[i - 1].Tok->is(tok::string_literal)) {
605 if (!Changes[i].Tok->is(tok::comment))
608 if (Changes[i].Tok->is(tok::comma)) {
610 } else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) {
613 AlignTokens(Style, Matches, Changes, i, ACS, RightJustify);
618 if (!Matches(Changes[i]))
632 unsigned ChangeWidthLeft = Changes[i].StartOfTokenColumn;
637 ChangeWidthAnchor = Changes[i].TokenLength;
639 ChangeWidthLeft += Changes[i].TokenLength;
641 ChangeWidthRight = Changes[i].TokenLength;
642 for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
643 ChangeWidthRight += Changes[j].Spaces;
644 // Changes are generally 1:1 with the tokens, but a change could also be
648 // Therefore, changes inside of a token should only count the space.
649 if (!Changes[j].IsInsideToken)
650 ChangeWidthRight += Changes[j].TokenLength;
688 SmallVector<WhitespaceManager::Change, 16> &Changes) { in AlignMacroSequence() argument
695 if (Changes[I].NewlinesBefore > 0) { in AlignMacroSequence()
701 // spaces it has to be shifted, so the rest of the changes on the line are in AlignMacroSequence()
703 if (!FoundMatchOnLine && AlignMacrosMatches(Changes[I])) { in AlignMacroSequence()
705 Shift = MinColumn - Changes[I].StartOfTokenColumn; in AlignMacroSequence()
706 Changes[I].Spaces += Shift; in AlignMacroSequence()
710 Changes[I].StartOfTokenColumn += Shift; in AlignMacroSequence()
711 if (I + 1 != Changes.size()) in AlignMacroSequence()
712 Changes[I + 1].PreviousEndOfTokenColumn += Shift; in AlignMacroSequence()
769 for (unsigned E = Changes.size(); I != E; ++I) { in alignConsecutiveMacros()
770 if (Changes[I].NewlinesBefore != 0) { in alignConsecutiveMacros()
774 bool EmptyLineBreak = (Changes[I].NewlinesBefore > 1) && in alignConsecutiveMacros()
785 FoundMatchOnLine, AlignMacrosMatches, Changes); in alignConsecutiveMacros()
793 if (!Changes[I].Tok->is(tok::comment)) in alignConsecutiveMacros()
796 if (!AlignMacrosMatches(Changes[I])) in alignConsecutiveMacros()
804 unsigned ChangeMinColumn = Changes[I].StartOfTokenColumn; in alignConsecutiveMacros()
805 int LineLengthAfter = -Changes[I].Spaces; in alignConsecutiveMacros()
806 for (unsigned j = I; j != E && Changes[j].NewlinesBefore == 0; ++j) in alignConsecutiveMacros()
807 LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength; in alignConsecutiveMacros()
816 FoundMatchOnLine, AlignMacrosMatches, Changes); in alignConsecutiveMacros()
831 if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0) in alignConsecutiveAssignments()
843 Changes, /*StartAt=*/0, Style.AlignConsecutiveAssignments, in alignConsecutiveAssignments()
859 if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0) in alignConsecutiveBitFields()
864 Changes, /*StartAt=*/0, Style.AlignConsecutiveBitFields); in alignConsecutiveBitFields()
896 Changes, /*StartAt=*/0, Style.AlignConsecutiveDeclarations); in alignConsecutiveDeclarations()
911 Changes, /*StartAt=*/0); in alignChainedConditionals()
923 for (Change &C : Changes) in alignChainedConditionals()
933 &C != &Changes.back() && (&C + 1)->NewlinesBefore == 0 && in alignChainedConditionals()
937 Changes, /*StartAt=*/0); in alignChainedConditionals()
951 for (unsigned i = 0, e = Changes.size(); i != e; ++i) { in alignTrailingComments()
952 if (Changes[i].StartOfBlockComment) in alignTrailingComments()
954 Newlines += Changes[i].NewlinesBefore; in alignTrailingComments()
955 if (!Changes[i].IsTrailingComment) in alignTrailingComments()
960 Changes[i].OriginalWhitespaceRange.getEnd().getRawEncoding() - in alignTrailingComments()
961 Changes[i].OriginalWhitespaceRange.getBegin().getRawEncoding() - in alignTrailingComments()
962 Changes[i].Tok->NewlinesBefore; in alignTrailingComments()
963 unsigned RestoredLineLength = Changes[i].StartOfTokenColumn + in alignTrailingComments()
964 Changes[i].TokenLength + OriginalSpaces; in alignTrailingComments()
969 Changes[i].Spaces = OriginalSpaces; in alignTrailingComments()
973 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn; in alignTrailingComments()
978 else if (Style.ColumnLimit >= Changes[i].TokenLength) in alignTrailingComments()
979 ChangeMaxColumn = Style.ColumnLimit - Changes[i].TokenLength; in alignTrailingComments()
985 if (!Changes[i].CreateReplacement) in alignTrailingComments()
988 if (i + 1 != e && Changes[i + 1].ContinuesPPDirective) in alignTrailingComments()
992 bool FollowsRBraceInColumn0 = i > 0 && Changes[i].NewlinesBefore == 0 && in alignTrailingComments()
993 Changes[i - 1].Tok->is(tok::r_brace) && in alignTrailingComments()
994 Changes[i - 1].StartOfTokenColumn == 0; in alignTrailingComments()
996 if (Changes[i].NewlinesBefore >= 1) { // A comment on its own line. in alignTrailingComments()
998 Changes[i].OriginalWhitespaceRange.getEnd()); in alignTrailingComments()
1000 if (Changes[j].Tok->is(tok::comment)) in alignTrailingComments()
1004 Changes[j].OriginalWhitespaceRange.getEnd()); in alignTrailingComments()
1023 (Changes[i].NewlinesBefore == 1 && i > 0 && in alignTrailingComments()
1024 !Changes[i - 1].IsTrailingComment) || in alignTrailingComments()
1034 BreakBeforeNext = (i == 0) || (Changes[i].NewlinesBefore > 1) || in alignTrailingComments()
1037 (Changes[i].NewlinesBefore == 1 && StartOfSequence == i); in alignTrailingComments()
1040 alignTrailingComments(StartOfSequence, Changes.size(), MinColumn); in alignTrailingComments()
1047 if (Changes[i].IsTrailingComment) in alignTrailingComments()
1048 Shift = Column - Changes[i].StartOfTokenColumn; in alignTrailingComments()
1049 if (Changes[i].StartOfBlockComment) { in alignTrailingComments()
1050 Shift = Changes[i].IndentationOffset + in alignTrailingComments()
1051 Changes[i].StartOfBlockComment->StartOfTokenColumn - in alignTrailingComments()
1052 Changes[i].StartOfTokenColumn; in alignTrailingComments()
1056 Changes[i].Spaces += Shift; in alignTrailingComments()
1057 if (i + 1 != Changes.size()) in alignTrailingComments()
1058 Changes[i + 1].PreviousEndOfTokenColumn += Shift; in alignTrailingComments()
1059 Changes[i].StartOfTokenColumn += Shift; in alignTrailingComments()
1070 for (unsigned i = 1, e = Changes.size(); i < e; ++i) { in alignEscapedNewlines()
1071 Change &C = Changes[i]; in alignEscapedNewlines()
1082 alignEscapedNewlines(StartOfMacro + 1, Changes.size(), MaxEndOfLine); in alignEscapedNewlines()
1088 Change &C = Changes[i]; in alignEscapedNewlines()
1103 for (unsigned ChangeIndex = 1U, ChangeEnd = Changes.size(); in alignArrayInitializers()
1105 auto &C = Changes[ChangeIndex]; in alignArrayInitializers()
1110 if (Changes[InsideIndex].Tok == C.Tok->MatchingParen) { in alignArrayInitializers()
1145 if (Changes[CellIter->Index].Tok->is(tok::r_brace)) { in alignArrayInitializersRightJustified()
1151 const FormatToken *Previous = Changes[Next->Index].Tok->Previous; in alignArrayInitializersRightJustified()
1153 Changes[Next->Index].Spaces = 0; in alignArrayInitializersRightJustified()
1154 Changes[Next->Index].NewlinesBefore = 0; in alignArrayInitializersRightJustified()
1167 Changes[CellIter->Index].Spaces = (MaxNetWidth - ThisNetWidth); in alignArrayInitializersRightJustified()
1176 Changes[Next->Index].Spaces = (MaxNetWidth - ThisNetWidth); in alignArrayInitializersRightJustified()
1184 if (Changes[CellIter->Index].NewlinesBefore == 0) { in alignArrayInitializersRightJustified()
1185 Changes[CellIter->Index].Spaces = (CellWidth - (ThisWidth + NetWidth)); in alignArrayInitializersRightJustified()
1186 Changes[CellIter->Index].Spaces += (i > 0) ? 1 : 0; in alignArrayInitializersRightJustified()
1193 if (Changes[Next->Index].NewlinesBefore == 0) { in alignArrayInitializersRightJustified()
1194 Changes[Next->Index].Spaces = (CellWidth - ThisWidth); in alignArrayInitializersRightJustified()
1195 Changes[Next->Index].Spaces += (i > 0) ? 1 : 0; in alignArrayInitializersRightJustified()
1213 if (Changes[CellIter->Index].NewlinesBefore == 0) in alignArrayInitializersLeftJustified()
1214 Changes[CellIter->Index].Spaces = 0; in alignArrayInitializersLeftJustified()
1216 Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces; in alignArrayInitializersLeftJustified()
1224 if (Changes[CellIter->Index].NewlinesBefore == 0) { in alignArrayInitializersLeftJustified()
1225 Changes[CellIter->Index].Spaces = in alignArrayInitializersLeftJustified()
1227 (Changes[CellIter->Index].Tok->isNot(tok::r_brace) ? 1 : 0); in alignArrayInitializersLeftJustified()
1238 if (Changes[Next->Index].NewlinesBefore == 0) { in alignArrayInitializersLeftJustified()
1239 Changes[Next->Index].Spaces = in alignArrayInitializersLeftJustified()
1241 (Changes[Next->Index].Tok->isNot(tok::r_brace) ? 1 : 0); in alignArrayInitializersLeftJustified()
1271 auto &C = Changes[i]; in getCells()
1284 for (; Changes[j].NewlinesBefore == 0 && j > Start; --j) { in getCells()
1285 InitialSpaces += Changes[j].Spaces + Changes[j].TokenLength; in getCells()
1286 InitialTokenLength += Changes[j].TokenLength; in getCells()
1289 InitialSpaces += Changes[j].Spaces + Changes[j].TokenLength; in getCells()
1290 InitialTokenLength += Changes[j].TokenLength; in getCells()
1311 while (Changes[j].Tok != NextNonComment && j < End) in getCells()
1313 if (j < End && Changes[j].NewlinesBefore == 0 && in getCells()
1314 Changes[j].Tok->isNot(tok::r_brace)) { in getCells()
1315 Changes[j].NewlinesBefore = 1; in getCells()
1317 Changes[j].Spaces = InitialSpaces - InitialTokenLength; in getCells()
1321 C.Spaces = Changes[i - 1].Tok->is(tok::comma) ? 1 : 2; in getCells()
1326 for (; j > 0 && !Changes[j].Tok->ArrayInitializerLineStart; --j) in getCells()
1328 EndSpaces = Changes[j].Spaces; in getCells()
1338 if (Changes[i].NewlinesBefore > 0) { in getCells()
1354 if ((j - 1) > Start && Changes[j].Tok->is(tok::comma) && in getCells()
1355 Changes[j - 1].NewlinesBefore > 0) { in getCells()
1357 auto LineLimit = Changes[j].Spaces + Changes[j].TokenLength; in getCells()
1359 Changes[i].NewlinesBefore = 0; in getCells()
1360 Changes[i].Spaces = 1; in getCells()
1364 while (Changes[i].NewlinesBefore > 0 && Changes[i].Tok == C.Tok) { in getCells()
1365 Changes[i].Spaces = InitialSpaces; in getCells()
1369 if (Changes[i].Tok != C.Tok) in getCells()
1382 if (Changes[i].NewlinesBefore > 0) in calculateCellWidth()
1384 CellWidth += Changes[i].TokenLength; in calculateCellWidth()
1385 CellWidth += (WithSpaces ? Changes[i].Spaces : 0); in calculateCellWidth()
1396 if (Changes[i].NewlinesBefore > 0) in alignToStartOfCell()
1397 Changes[i].Spaces = Changes[Start].Spaces; in alignToStartOfCell()
1418 for (unsigned i = 0, e = Changes.size(); i != e; ++i) { in generateChanges()
1419 const Change &C = Changes[i]; in generateChanges()
1420 if (i > 0 && Changes[i - 1].OriginalWhitespaceRange.getBegin() == in generateChanges()