Lines Matching full:changes
60 Changes.push_back(Change(Tok, /*CreateReplacement=*/true, Tok.WhitespaceRange,
70 Changes.push_back(Change(Tok, /*CreateReplacement=*/false,
95 Changes.push_back(
104 if (Changes.empty())
107 llvm::sort(Changes, Change::IsBeforeInFile(SourceMgr));
130 Changes[0].PreviousEndOfTokenColumn = 0;
131 Change *LastOutsideTokenChange = &Changes[0];
132 for (unsigned I = 1, e = Changes.size(); I != e; ++I) {
133 auto &C = Changes[I];
134 auto &P = Changes[I - 1];
151 // Usually consecutive changes would occur in consecutive tokens. This is
162 // and 3. So the two consecutive whitespace changes just before '// line 2'
169 // For this reason, if the text between consecutive changes spans multiple
183 // If there are multiple changes in this token, sum up all the changes until
197 // BreakableLineCommentSection does comment reflow changes and here is
204 // That amounts to 2 changes by BreakableLineCommentSection:
212 // So in the end we have two changes like this:
230 Changes.back().TokenLength = 0;
231 Changes.back().IsTrailingComment = Changes.back().Tok->is(tok::comment);
234 for (auto &Change : Changes) {
235 // Reset the IsTrailingComment flag for changes inside of trailing comments
261 for (auto &Change : Changes) {
289 SmallVector<WhitespaceManager::Change, 16> &Changes) {
316 auto &CurrentChange = Changes[i];
319 Changes[ScopeStack.back()].indentAndNestingLevel()) {
327 Changes[PreviousNonComment].Tok->is(tok::comment)) {
331 Changes[PreviousNonComment].indentAndNestingLevel()) {
338 Changes[i - 1].Tok->is(tok::string_literal);
347 // spaces it has to be shifted, so the rest of the changes on the line are
372 if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName))
376 if (Changes[ScopeStart - 1].Tok->is(TT_LambdaLBrace))
381 Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName)) {
387 Changes[ScopeStart - 2].Tok->isOneOf(tok::identifier,
389 Changes[ScopeStart - 1].Tok->is(tok::l_paren) &&
390 Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) {
395 if (Changes[ScopeStart].NewlinesBefore > 0)
420 Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
421 Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
429 Changes[ScopeStart - 2].Tok->isNot(tok::identifier) &&
430 Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
435 Changes[OuterScopeStart - 1].Tok->is(TT_LambdaLBrace)) {
439 if (Changes[ScopeStart].NewlinesBefore > 0)
445 if (Changes[ScopeStart - 1].Tok->is(TT_TemplateOpener))
459 assert(Shift > 0 || Changes[i].NewlinesBefore > 0 ||
461 static_cast<int>(Changes[i].Tok->SpacesRequiredBefore) ||
465 if (i + 1 != Changes.size())
466 Changes[i + 1].PreviousEndOfTokenColumn += Shift;
479 Previous >= 0 && Changes[Previous].Tok->is(TT_PointerOrReference);
481 assert(Changes[Previous].Tok->isPointerOrReference());
482 if (Changes[Previous].Tok->isNot(tok::star)) {
488 Changes[Previous + 1].Spaces -= Shift;
489 Changes[Previous].Spaces += Shift;
490 Changes[Previous].StartOfTokenColumn += Shift;
496 // Walk through a subset of the changes, starting at StartAt, and find
503 // exhausted all items inside Changes, or because we hit a scope level higher
506 // equal to the initial level, which is the level of Changes[StartAt].
529 SmallVector<WhitespaceManager::Change, 16> &Changes,
555 auto IndentAndNestingLevel = StartAt < Changes.size()
556 ? Changes[StartAt].indentAndNestingLevel()
582 Changes);
592 for (unsigned e = Changes.size(); i != e; ++i) {
593 auto &CurrentChange = Changes[i];
616 Changes[i - 1].Tok->isNot(tok::string_literal)) {
630 AlignTokens(Style, Matches, Changes, i, ACS, RightJustify);
659 for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
660 ChangeWidthRight += Changes[j].Spaces;
661 // Changes are generally 1:1 with the tokens, but a change could also be
665 // Therefore, changes inside of a token should only count the space.
666 if (!Changes[j].IsInsideToken)
667 ChangeWidthRight += Changes[j].TokenLength;
704 SmallVector<WhitespaceManager::Change, 16> &Changes) {
710 if (Changes[I].NewlinesBefore > 0) {
716 // spaces it has to be shifted, so the rest of the changes on the line are
718 if (!FoundMatchOnLine && Matches(Changes[I])) {
720 Shift = MinColumn - Changes[I].StartOfTokenColumn;
721 Changes[I].Spaces += Shift;
725 Changes[I].StartOfTokenColumn += Shift;
726 if (I + 1 != Changes.size())
727 Changes[I + 1].PreviousEndOfTokenColumn += Shift;
782 for (unsigned E = Changes.size(); I != E; ++I) {
783 if (Changes[I].NewlinesBefore != 0) {
787 bool EmptyLineBreak = (Changes[I].NewlinesBefore > 1) &&
798 AlignMacrosMatches, Changes);
806 if (Changes[I].Tok->isNot(tok::comment))
809 if (!AlignMacrosMatches(Changes[I]))
817 unsigned ChangeMinColumn = Changes[I].StartOfTokenColumn;
823 AlignMacrosMatches, Changes);
838 if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)
855 Changes, /*StartAt=*/0, Style.AlignConsecutiveAssignments,
876 if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)
881 Changes, /*StartAt=*/0, AlignStyle);
902 // different changes, which will cause incorrect alignment as we'll
925 for (unsigned E = Changes.size(); I != E; ++I) {
926 if (Changes[I].NewlinesBefore != 0) {
929 (Changes[I].NewlinesBefore > 1) &&
942 Matches, Changes);
952 if (Changes[I].Tok->isNot(tok::comment))
955 if (Changes[I].Tok->is(Type)) {
957 !Changes[I].Tok->Next || Changes[I].Tok->Next->isTrailingComment();
962 std::max(MinEmptyCaseColumn, Changes[I].StartOfTokenColumn);
965 std::max(MinEmptyCaseColumn, Changes[I].StartOfTokenColumn + 2);
970 if (!Matches(Changes[I]))
983 MinColumn = std::max(MinColumn, Changes[I].StartOfTokenColumn);
990 Changes);
1044 Changes, /*StartAt=*/0, Style.AlignConsecutiveDeclarations);
1059 Changes, /*StartAt=*/0);
1071 for (Change &C : Changes)
1081 &C != &Changes.back() && (&C + 1)->NewlinesBefore == 0 &&
1085 Changes, /*StartAt=*/0);
1093 const int Size = Changes.size();
1102 auto &C = Changes[I];
1139 if (I + 1 < Size && Changes[I + 1].ContinuesPPDirective &&
1149 if (Changes[J].Tok->is(tok::comment))
1153 Changes[J].OriginalWhitespaceRange.getEnd());
1198 DontAlignThisComment(Changes[I - 1].Tok)) {
1210 !Changes[I - 1].IsTrailingComment) ||
1233 if (Changes[i].IsTrailingComment)
1234 Shift = Column - Changes[i].StartOfTokenColumn;
1235 if (Changes[i].StartOfBlockComment) {
1236 Shift = Changes[i].IndentationOffset +
1237 Changes[i].StartOfBlockComment->StartOfTokenColumn -
1238 Changes[i].StartOfTokenColumn;
1242 Changes[i].Spaces += Shift;
1243 if (i + 1 != Changes.size())
1244 Changes[i + 1].PreviousEndOfTokenColumn += Shift;
1245 Changes[i].StartOfTokenColumn += Shift;
1259 for (unsigned i = 1, e = Changes.size(); i < e; ++i) {
1260 Change &C = Changes[i];
1275 alignEscapedNewlines(StartOfMacro + 1, Changes.size(), MaxEndOfLine);
1281 Change &C = Changes[i];
1296 for (unsigned ChangeIndex = 1U, ChangeEnd = Changes.size();
1298 auto &C = Changes[ChangeIndex];
1303 if (Changes[InsideIndex].Tok == C.Tok->MatchingParen) {
1339 if (Changes[CellIter->Index].Tok->is(tok::r_brace)) {
1345 const FormatToken *Previous = Changes[Next->Index].Tok->Previous;
1347 Changes[Next->Index].Spaces = BracePadding;
1348 Changes[Next->Index].NewlinesBefore = 0;
1361 Changes[CellIter->Index].Spaces = (MaxNetWidth - ThisNetWidth);
1372 Changes[Next->Index].Spaces = (MaxNetWidth - ThisNetWidth);
1380 if (Changes[CellIter->Index].NewlinesBefore == 0) {
1381 Changes[CellIter->Index].Spaces = (CellWidth - (ThisWidth + NetWidth));
1382 Changes[CellIter->Index].Spaces += (i > 0) ? 1 : BracePadding;
1389 if (Changes[Next->Index].NewlinesBefore == 0) {
1390 Changes[Next->Index].Spaces = (CellWidth - ThisWidth);
1391 Changes[Next->Index].Spaces += (i > 0) ? 1 : BracePadding;
1411 auto &Change = Changes[Next->Index];
1422 if (Changes[CellIter->Index].NewlinesBefore == 0) {
1423 Changes[CellIter->Index].Spaces =
1425 (Changes[CellIter->Index].Tok->isNot(tok::r_brace) ? 1
1437 if (Changes[Next->Index].NewlinesBefore == 0) {
1438 Changes[Next->Index].Spaces =
1440 (Changes[Next->Index].Tok->isNot(tok::r_brace) ? 1 : BracePadding);
1470 auto &C = Changes[i];
1483 for (; Changes[j].NewlinesBefore == 0 && j > Start; --j) {
1484 InitialSpaces += Changes[j].Spaces + Changes[j].TokenLength;
1485 InitialTokenLength += Changes[j].TokenLength;
1488 InitialSpaces += Changes[j].Spaces + Changes[j].TokenLength;
1489 InitialTokenLength += Changes[j].TokenLength;
1512 while (j < End && Changes[j].Tok != NextNonComment)
1514 if (j < End && Changes[j].NewlinesBefore == 0 &&
1515 Changes[j].Tok->isNot(tok::r_brace)) {
1516 Changes[j].NewlinesBefore = 1;
1518 Changes[j].Spaces = InitialSpaces - InitialTokenLength;
1522 C.Spaces = Changes[i - 1].Tok->is(tok::comma) ? 1 : 2;
1527 for (; j > 0 && !Changes[j].Tok->ArrayInitializerLineStart; --j)
1529 EndSpaces = Changes[j].Spaces;
1539 if (Changes[i].NewlinesBefore > 0) {
1555 if ((j - 1) > Start && Changes[j].Tok->is(tok::comma) &&
1556 Changes[j - 1].NewlinesBefore > 0) {
1558 auto LineLimit = Changes[j].Spaces + Changes[j].TokenLength;
1560 Changes[i].NewlinesBefore = 0;
1561 Changes[i].Spaces = 1;
1565 while (Changes[i].NewlinesBefore > 0 && Changes[i].Tok == C.Tok) {
1566 Changes[i].Spaces = InitialSpaces;
1570 if (Changes[i].Tok != C.Tok)
1583 if (Changes[i].NewlinesBefore > 0)
1585 CellWidth += Changes[i].TokenLength;
1586 CellWidth += (WithSpaces ? Changes[i].Spaces : 0);
1597 if (Changes[i].NewlinesBefore > 0)
1598 Changes[i].Spaces = Changes[Start].Spaces;
1618 for (unsigned i = 0, e = Changes.size(); i != e; ++i) {
1619 const Change &C = Changes[i];
1621 auto Last = Changes[i - 1].OriginalWhitespaceRange;
1622 auto New = Changes[i].OriginalWhitespaceRange;
1648 // comes from ContinuationIndenter::addTokenOnCurrentLine when it changes