[clang] [clang-format] Merge case alignment into AlignTokens (PR #187811)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 21 14:10:54 PDT 2026
================
@@ -473,10 +478,14 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
// When RightJustify and ACS.PadOperators are true, operators in each block to
// be aligned will be padded on the left to the same length before aligning.
//
-// The simple check will not look at the indentaion and nesting level to recurse
-// into the line for alignment. It will also not count the commas. This is e.g.
-// for aligning macro definitions.
-template <typename F, bool SimpleCheck = false>
+// For the Macro or CaseX strategy we will not look at the indentaion and
+// nesting level to recurse into the line for alignment. We will also not count
+// the commas.
+//
+// The CaseX strategies also have some special handling, because we need to be
+// able align empty cases (rsp. use the position to push out other case bodies),
+// but stop on non short cases, which needs a bit of lookahead.
+template <typename F, AlignStrategy Strategy = AlignStrategy::Normal>
----------------
HazardyKnusperkeks wrote:
Why do you want to move it to a parameter? I think it's easier for the compiler to eliminate checks etc. when it is a template parameter. Because the type of `Matches` is a template, each alignment already get its own version.
https://github.com/llvm/llvm-project/pull/187811
More information about the cfe-commits
mailing list