[clang] [clang-format][NFC] AlignTokenSequence: Rename Changes[i] to CurrentC… (PR #68153)
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/68153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] AlignTokenSequence: Rename Changes[i] to CurrentC… (PR #68153)
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/68153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] AlignTokenSequence: Rename Changes[i] to CurrentC… (PR #68153)
llvmbot wrote: @llvm/pr-subscribers-clang-format Changes …hange To improve debugging experience. --- Full diff: https://github.com/llvm/llvm-project/pull/68153.diff 1 Files Affected: - (modified) clang/lib/Format/WhitespaceManager.cpp (+31-30) ``diff diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 2cbde3da212ec65..73d61c3d53c8341 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -307,8 +307,9 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, SmallVector ScopeStack; for (unsigned i = Start; i != End; ++i) { +auto = Changes[i]; if (ScopeStack.size() != 0 && -Changes[i].indentAndNestingLevel() < +CurrentChange.indentAndNestingLevel() < Changes[ScopeStack.back()].indentAndNestingLevel()) { ScopeStack.pop_back(); } @@ -320,18 +321,18 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, Changes[PreviousNonComment].Tok->is(tok::comment)) { --PreviousNonComment; } -if (i != Start && Changes[i].indentAndNestingLevel() > +if (i != Start && CurrentChange.indentAndNestingLevel() > Changes[PreviousNonComment].indentAndNestingLevel()) { ScopeStack.push_back(i); } bool InsideNestedScope = ScopeStack.size() != 0; bool ContinuedStringLiteral = i > Start && - Changes[i].Tok->is(tok::string_literal) && + CurrentChange.Tok->is(tok::string_literal) && Changes[i - 1].Tok->is(tok::string_literal); bool SkipMatchCheck = InsideNestedScope || ContinuedStringLiteral; -if (Changes[i].NewlinesBefore > 0 && !SkipMatchCheck) { +if (CurrentChange.NewlinesBefore > 0 && !SkipMatchCheck) { Shift = 0; FoundMatchOnLine = false; } @@ -339,23 +340,23 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, // If this is the first matching token to be aligned, remember by how many // spaces it has to be shifted, so the rest of the changes on the line are // shifted by the same amount -if (!FoundMatchOnLine && !SkipMatchCheck && Matches(Changes[i])) { +if (!FoundMatchOnLine && !SkipMatchCheck && Matches(CurrentChange)) { FoundMatchOnLine = true; - Shift = Column - (RightJustify ? Changes[i].TokenLength : 0) - - Changes[i].StartOfTokenColumn; - Changes[i].Spaces += Shift; + Shift = Column - (RightJustify ? CurrentChange.TokenLength : 0) - + CurrentChange.StartOfTokenColumn; + CurrentChange.Spaces += Shift; // FIXME: This is a workaround that should be removed when we fix // http://llvm.org/PR53699. An assertion later below verifies this. - if (Changes[i].NewlinesBefore == 0) { -Changes[i].Spaces = -std::max(Changes[i].Spaces, - static_cast(Changes[i].Tok->SpacesRequiredBefore)); + if (CurrentChange.NewlinesBefore == 0) { +CurrentChange.Spaces = +std::max(CurrentChange.Spaces, + static_cast(CurrentChange.Tok->SpacesRequiredBefore)); } } // This is for function parameters that are split across multiple lines, // as mentioned in the ScopeStack comment. -if (InsideNestedScope && Changes[i].NewlinesBefore > 0) { +if (InsideNestedScope && CurrentChange.NewlinesBefore > 0) { unsigned ScopeStart = ScopeStack.back(); auto ShouldShiftBeAdded = [&] { // Function declaration @@ -378,30 +379,30 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, TT_TemplateCloser) && Changes[ScopeStart - 1].Tok->is(tok::l_paren) && Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) { - if (Changes[i].Tok->MatchingParen && - Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace)) { + if (CurrentChange.Tok->MatchingParen && + CurrentChange.Tok->MatchingParen->is(TT_LambdaLBrace)) { return false; } if (Changes[ScopeStart].NewlinesBefore > 0) return false; - if (Changes[i].Tok->is(tok::l_brace) && - Changes[i].Tok->is(BK_BracedInit)) { + if (CurrentChange.Tok->is(tok::l_brace) && + CurrentChange.Tok->is(BK_BracedInit)) { return true; } return Style.BinPackArguments; } // Ternary operator -if (Changes[i].Tok->is(TT_ConditionalExpr)) +if (CurrentChange.Tok->is(TT_ConditionalExpr)) return true; // Period Initializer .XXX = 1. -if (Changes[i].Tok->is(TT_DesignatedInitializerPeriod)) +if (CurrentChange.Tok->is(TT_DesignatedInitializerPeriod)) return true;
[clang] [clang-format][NFC] AlignTokenSequence: Rename Changes[i] to CurrentC… (PR #68153)
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/68153 …hange To improve debugging experience. From ae3cc1f37e4b0f3640250f4f0ac58c9c7c4f2ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Tue, 3 Oct 2023 17:31:21 +0200 Subject: [PATCH] [clang-format][NFC] AlignTokenSequence: Rename Changes[i] to CurrentChange To improve debugging experience. --- clang/lib/Format/WhitespaceManager.cpp | 61 +- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 2cbde3da212ec65..73d61c3d53c8341 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -307,8 +307,9 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, SmallVector ScopeStack; for (unsigned i = Start; i != End; ++i) { +auto = Changes[i]; if (ScopeStack.size() != 0 && -Changes[i].indentAndNestingLevel() < +CurrentChange.indentAndNestingLevel() < Changes[ScopeStack.back()].indentAndNestingLevel()) { ScopeStack.pop_back(); } @@ -320,18 +321,18 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, Changes[PreviousNonComment].Tok->is(tok::comment)) { --PreviousNonComment; } -if (i != Start && Changes[i].indentAndNestingLevel() > +if (i != Start && CurrentChange.indentAndNestingLevel() > Changes[PreviousNonComment].indentAndNestingLevel()) { ScopeStack.push_back(i); } bool InsideNestedScope = ScopeStack.size() != 0; bool ContinuedStringLiteral = i > Start && - Changes[i].Tok->is(tok::string_literal) && + CurrentChange.Tok->is(tok::string_literal) && Changes[i - 1].Tok->is(tok::string_literal); bool SkipMatchCheck = InsideNestedScope || ContinuedStringLiteral; -if (Changes[i].NewlinesBefore > 0 && !SkipMatchCheck) { +if (CurrentChange.NewlinesBefore > 0 && !SkipMatchCheck) { Shift = 0; FoundMatchOnLine = false; } @@ -339,23 +340,23 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, // If this is the first matching token to be aligned, remember by how many // spaces it has to be shifted, so the rest of the changes on the line are // shifted by the same amount -if (!FoundMatchOnLine && !SkipMatchCheck && Matches(Changes[i])) { +if (!FoundMatchOnLine && !SkipMatchCheck && Matches(CurrentChange)) { FoundMatchOnLine = true; - Shift = Column - (RightJustify ? Changes[i].TokenLength : 0) - - Changes[i].StartOfTokenColumn; - Changes[i].Spaces += Shift; + Shift = Column - (RightJustify ? CurrentChange.TokenLength : 0) - + CurrentChange.StartOfTokenColumn; + CurrentChange.Spaces += Shift; // FIXME: This is a workaround that should be removed when we fix // http://llvm.org/PR53699. An assertion later below verifies this. - if (Changes[i].NewlinesBefore == 0) { -Changes[i].Spaces = -std::max(Changes[i].Spaces, - static_cast(Changes[i].Tok->SpacesRequiredBefore)); + if (CurrentChange.NewlinesBefore == 0) { +CurrentChange.Spaces = +std::max(CurrentChange.Spaces, + static_cast(CurrentChange.Tok->SpacesRequiredBefore)); } } // This is for function parameters that are split across multiple lines, // as mentioned in the ScopeStack comment. -if (InsideNestedScope && Changes[i].NewlinesBefore > 0) { +if (InsideNestedScope && CurrentChange.NewlinesBefore > 0) { unsigned ScopeStart = ScopeStack.back(); auto ShouldShiftBeAdded = [&] { // Function declaration @@ -378,30 +379,30 @@ AlignTokenSequence(const FormatStyle , unsigned Start, unsigned End, TT_TemplateCloser) && Changes[ScopeStart - 1].Tok->is(tok::l_paren) && Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) { - if (Changes[i].Tok->MatchingParen && - Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace)) { + if (CurrentChange.Tok->MatchingParen && + CurrentChange.Tok->MatchingParen->is(TT_LambdaLBrace)) { return false; } if (Changes[ScopeStart].NewlinesBefore > 0) return false; - if (Changes[i].Tok->is(tok::l_brace) && - Changes[i].Tok->is(BK_BracedInit)) { + if (CurrentChange.Tok->is(tok::l_brace) && + CurrentChange.Tok->is(BK_BracedInit)) { return true; } return Style.BinPackArguments; } // Ternary operator -if (Changes[i].Tok->is(TT_ConditionalExpr)) +