[clang] [clang-format] Respect ColumnLimit while aligning multiline expressions (PR #163863)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 18 13:47:29 PDT 2025
================
@@ -552,37 +553,76 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
// If there is more than one matching token per line, or if the number of
// preceding commas, do not match anymore, end the sequence.
if (FoundMatchOnLine || CommasBeforeMatch != CommasBeforeLastMatch) {
- MatchedIndices.push_back(i);
+ MatchedIndices.push_back(I);
AlignCurrentSequence();
}
CommasBeforeLastMatch = CommasBeforeMatch;
FoundMatchOnLine = true;
if (StartOfSequence == 0)
- StartOfSequence = i;
+ StartOfSequence = I;
unsigned ChangeWidthLeft = CurrentChange.StartOfTokenColumn;
unsigned ChangeWidthAnchor = 0;
unsigned ChangeWidthRight = 0;
+ unsigned CurrentChangeWidthRight = 0;
if (RightJustify)
if (ACS.PadOperators)
ChangeWidthAnchor = CurrentChange.TokenLength;
else
ChangeWidthLeft += CurrentChange.TokenLength;
else
- ChangeWidthRight = CurrentChange.TokenLength;
- for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
- ChangeWidthRight += Changes[j].Spaces;
+ CurrentChangeWidthRight = CurrentChange.TokenLength;
+ llvm::SmallPtrSet<const FormatToken *, 8> MatchingParensToEncounter;
----------------
HazardyKnusperkeks wrote:
It should, never thought about it. I've adapted the code.
https://github.com/llvm/llvm-project/pull/163863
More information about the cfe-commits
mailing list