[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:54 PDT 2026


================
@@ -1633,8 +1633,16 @@ static auto computeNewlines(const AnnotatedLine &Line,
                             const SmallVectorImpl<AnnotatedLine *> &Lines,
                             const FormatStyle &Style) {
   const auto &RootToken = *Line.First;
-  auto Newlines =
-      std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
+
+  unsigned MaxNewlines = Style.MaxEmptyLinesToKeep + 1;
+  if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Always &&
+      RootToken.NewlinesBefore > 1 && PreviousLine &&
+      !RootToken.is(tok::l_brace) && Line.MightBeFunctionDecl &&
----------------
HazardyKnusperkeks wrote:

Why the check for `MightBeFunctionDecl`? 

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


More information about the cfe-commits mailing list