[clang] [clang-format] Respect definition separators when MaxEmptyLinesToKeep: 0 (PR #206406)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 12:03:55 PDT 2026


================
@@ -391,6 +391,40 @@ TEST_F(DefinitionBlockSeparatorTest, Always) {
                Style, Prefix + Infix + Postfix);
 }
 
+TEST_F(DefinitionBlockSeparatorTest, AlwaysMaxEmptyLinesZeroAllman) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  Style.MaxEmptyLinesToKeep = 0;
+  Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
+
+  constexpr StringRef Expected = "uint32_t my_function(uint32_t a1)\n"
+                                 "{\n"
+                                 "  uint32_t b = a1 + 1;\n"
+                                 "  return a1;\n"
+                                 "}\n"
+                                 "\n"
+                                 "uint32_t other_function(uint32_t a1)\n"
+                                 "{\n"
+                                 "  uint32_t b = a1 + 1;\n"
+                                 "  return a1;\n"
+                                 "}\n";
----------------
HazardyKnusperkeks wrote:

```suggestion
                                 "}";
```

https://github.com/llvm/llvm-project/pull/206406


More information about the cfe-commits mailing list