[clang] [clang-format] Add new option: WrapNamespaceBodyWithNewlines (PR #106145)

via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 28 02:17:22 PDT 2024


================
@@ -1493,6 +1511,18 @@ static auto computeNewlines(const AnnotatedLine &Line,
     Newlines = 1;
   }
 
+  // Insert empty line after "{" that opens namespace scope
+  if (Style.WrapNamespaceBodyWithNewlines &&
+      LineStartsNamespaceScope(&Line, PreviousLine, PrevPrevLine)) {
+    Newlines = 2;
----------------
dmasloff wrote:

I have not tested it yet, probably will add test about this in pr update, but since it's going later then all usings of `Style.MaxEmptyLinesToKeep` it overrides behavior of this option in namespaces, which seems reasonable. Could change it to `Newlines = std::min(2, Style.MaxEmptyLinesToKeep)` in `Leave` option if moving to proposed enum and existing`Newlines = 2` can be used for `Always`?

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


More information about the cfe-commits mailing list