[clang] [clang-format] Add KwBreakBeforeCaseLabel (PR #227668)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 1 11:51:18 PDT 2026
================
@@ -2833,6 +2833,56 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
Style);
}
+TEST_F(FormatTest, FormatsSwitchStatementKwBreakBeforeCase) {
+ FormatStyle Style = getLLVMStyle();
+ Style.IndentCaseLabels = true;
+ Style.KwBreakBeforeCaseLabel = true;
+
+ verifyFormat("switch (n) {\n"
+ " break; case 0:;\n"
+ "}",
+ Style);
+
+ verifyFormat("switch (n) {\n"
+ " break; case 0: {\n"
+ " return false;\n"
+ " }\n"
+ " break; case 1:\n"
+ " break; default: {\n"
+ " return true;\n"
+ " }\n"
+ "}",
+ Style);
+
+ verifyFormat("switch (n) {\n"
----------------
HazardyKnusperkeks wrote:
The two argument variant should suffice, it uses `messUp` to remove all whitespace and line breaks.
https://github.com/llvm/llvm-project/pull/227668
More information about the cfe-commits
mailing list