[clang] [clang-format][NFC] AlignTokenSequence: Skip loop iteration (PR #68154)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 3 13:14:41 PDT 2023


https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/68154

When Shift is 0 there does nothing happen in the remainder of the loop, express that directly.

>From cd77a3cce4497c12c1d65d2f41d71b4ef3b5c079 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 17:32:47 +0200
Subject: [PATCH] [clang-format][NFC] AlignTokenSequence: Skip loop iteration

When Shift is 0 there does nothing happen in the remainder of the loop,
express that directly.
---
 clang/lib/Format/WhitespaceManager.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index 2cbde3da212ec65..be8eb4f60f310c9 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -353,6 +353,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 && Changes[i].NewlinesBefore > 0) {



More information about the cfe-commits mailing list