[clang] [clang-format][NFC] AlignTokens: Rename Changes[i] to CurrentChange (PR #68152)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 3 13:11:13 PDT 2023
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/68152
To improve debugging experience.
>From 323ddd1948aa738419fd5afd848293b1a73e4cc4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= <bjoern at hazardy.de>
Date: Tue, 3 Oct 2023 16:26:18 +0200
Subject: [PATCH] [clang-format][NFC] AlignTokens: Rename Changes[i] to
CurrentChange
To improve debugging experience.
---
clang/lib/Format/WhitespaceManager.cpp | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index 2cbde3da212ec65..d732100e56ccab0 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -579,16 +579,17 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
unsigned i = StartAt;
for (unsigned e = Changes.size(); i != e; ++i) {
- if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel)
+ auto &CurrentChange = Changes[i];
+ if (CurrentChange.indentAndNestingLevel() < IndentAndNestingLevel)
break;
- if (Changes[i].NewlinesBefore != 0) {
+ if (CurrentChange.NewlinesBefore != 0) {
CommasBeforeMatch = 0;
EndOfSequence = i;
// Whether to break the alignment sequence because of an empty line.
bool EmptyLineBreak =
- (Changes[i].NewlinesBefore > 1) && !ACS.AcrossEmptyLines;
+ (CurrentChange.NewlinesBefore > 1) && !ACS.AcrossEmptyLines;
// Whether to break the alignment sequence because of a line without a
// match.
@@ -600,19 +601,19 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
// A new line starts, re-initialize line status tracking bools.
// Keep the match state if a string literal is continued on this line.
- if (i == 0 || Changes[i].Tok->isNot(tok::string_literal) ||
+ if (i == 0 || CurrentChange.Tok->isNot(tok::string_literal) ||
Changes[i - 1].Tok->isNot(tok::string_literal)) {
FoundMatchOnLine = false;
}
LineIsComment = true;
}
- if (Changes[i].Tok->isNot(tok::comment))
+ if (CurrentChange.Tok->isNot(tok::comment))
LineIsComment = false;
- if (Changes[i].Tok->is(tok::comma)) {
+ if (CurrentChange.Tok->is(tok::comma)) {
++CommasBeforeMatch;
- } else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) {
+ } else if (CurrentChange.indentAndNestingLevel() > IndentAndNestingLevel) {
// Call AlignTokens recursively, skipping over this scope block.
unsigned StoppedAt =
AlignTokens(Style, Matches, Changes, i, ACS, RightJustify);
@@ -620,7 +621,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
continue;
}
- if (!Matches(Changes[i]))
+ if (!Matches(CurrentChange))
continue;
// If there is more than one matching token per line, or if the number of
@@ -634,16 +635,16 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
if (StartOfSequence == 0)
StartOfSequence = i;
- unsigned ChangeWidthLeft = Changes[i].StartOfTokenColumn;
+ unsigned ChangeWidthLeft = CurrentChange.StartOfTokenColumn;
unsigned ChangeWidthAnchor = 0;
unsigned ChangeWidthRight = 0;
if (RightJustify)
if (ACS.PadOperators)
- ChangeWidthAnchor = Changes[i].TokenLength;
+ ChangeWidthAnchor = CurrentChange.TokenLength;
else
- ChangeWidthLeft += Changes[i].TokenLength;
+ ChangeWidthLeft += CurrentChange.TokenLength;
else
- ChangeWidthRight = Changes[i].TokenLength;
+ ChangeWidthRight = CurrentChange.TokenLength;
for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
ChangeWidthRight += Changes[j].Spaces;
// Changes are generally 1:1 with the tokens, but a change could also be
More information about the cfe-commits
mailing list