[clang] [clang-format] Respect definition separators when MaxEmptyLinesToKeep: 0 (PR #206406)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 26 12:56:15 PDT 2026
================
@@ -391,6 +391,37 @@ 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;
+ Style.AllowShortFunctionsOnASingleLine = FormatStyle::ShortFunctionStyle();
+
+ constexpr StringRef Input = "int my_function(int a)\n"
+ "\n"
+ "{\n"
+ " return a;\n"
+ "}\n"
+ "int other_function(int a)\n"
+ "\n"
+ "{\n"
+ " return a;\n"
+ "}\n";
+
+ constexpr StringRef Expected = "int my_function(int a)\n"
+ "{\n"
+ " return a;\n"
+ "}\n"
+ "\n"
+ "int other_function(int a)\n"
+ "{\n"
+ " return a;\n"
+ "}\n";
+
+ verifyFormat(Input, Style, Expected);
----------------
HazardyKnusperkeks wrote:
But the strings inline. Did you run the test? The order is wrong.
https://github.com/llvm/llvm-project/pull/206406
More information about the cfe-commits
mailing list