[clang] [clang-format][NFC] Simplify some logic in BreakableLineCommentSection (PR #148324)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 11 18:29:59 PDT 2025
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/148324
None
>From 88f34fb41704bdd6f6de743a5b467cdc3c938cc4 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Fri, 11 Jul 2025 18:18:18 -0700
Subject: [PATCH] [clang-format][NFC] Simplify some logic in
BreakableLineCommentSection
---
clang/lib/Format/BreakableToken.cpp | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index 24912c25ef8c6..c36cb74bc4501 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -927,14 +927,12 @@ BreakableLineCommentSection::BreakableLineCommentSection(
}
if (Lines[i].size() != IndentPrefix.size()) {
- PrefixSpaceChange[i] = FirstLineSpaceChange;
+ assert(Lines[i].size() > IndentPrefix.size());
- if (SpacesInPrefix + PrefixSpaceChange[i] < Minimum) {
- PrefixSpaceChange[i] +=
- Minimum - (SpacesInPrefix + PrefixSpaceChange[i]);
- }
+ PrefixSpaceChange[i] = SpacesInPrefix + FirstLineSpaceChange < Minimum
+ ? Minimum - SpacesInPrefix
+ : FirstLineSpaceChange;
- assert(Lines[i].size() > IndentPrefix.size());
const auto FirstNonSpace = Lines[i][IndentPrefix.size()];
const bool IsFormatComment = LineTok && switchesFormatting(*LineTok);
const bool LineRequiresLeadingSpace =
More information about the cfe-commits
mailing list