diff options
author | Björn Schäpers <bjoern@hazardy.de> | 2023-10-04 22:20:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-04 22:20:33 +0200 |
commit | b6f29191adb26ee870e624c414683cb3e6e03a87 (patch) | |
tree | 73abb8fee42dcd5691d7bbd0643e6a35569e4268 /clang/lib/Format/WhitespaceManager.cpp | |
parent | b7ac16c70faf7274119f393797ce89c054346f48 (diff) | |
download | llvm-b6f29191adb26ee870e624c414683cb3e6e03a87.zip llvm-b6f29191adb26ee870e624c414683cb3e6e03a87.tar.gz llvm-b6f29191adb26ee870e624c414683cb3e6e03a87.tar.bz2 |
[clang-format][NFC] AlignTokenSequence: Skip loop iteration
When Shift is 0 there does nothing happen in the remainder of the loop,
express that directly.
Diffstat (limited to 'clang/lib/Format/WhitespaceManager.cpp')
-rw-r--r-- | clang/lib/Format/WhitespaceManager.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 4718c02..dc81060 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -354,6 +354,9 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End, } } + if (Shift == 0) + continue; + // This is for function parameters that are split across multiple lines, // as mentioned in the ScopeStack comment. if (InsideNestedScope && CurrentChange.NewlinesBefore > 0) { @@ -447,7 +450,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End, CurrentChange.Spaces += Shift; // We should not remove required spaces unless we break the line before. - assert(Shift >= 0 || Changes[i].NewlinesBefore > 0 || + assert(Shift > 0 || Changes[i].NewlinesBefore > 0 || CurrentChange.Spaces >= static_cast<int>(Changes[i].Tok->SpacesRequiredBefore) || CurrentChange.Tok->is(tok::eof)); |