[clang] [clang-format] Add new option: WrapNamespaceBodyWithNewlines (PR #106145)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 30 17:26:37 PST 2024
================
@@ -1493,6 +1493,22 @@ static auto computeNewlines(const AnnotatedLine &Line,
Newlines = 1;
}
+ if (Style.WrapNamespaceBodyWithEmptyLines != FormatStyle::WNBWELS_Leave) {
+ // Modify empty lines after TT_NamespaceLBrace.
+ if (PreviousLine && PreviousLine->endsWith(TT_NamespaceLBrace)) {
+ if (Style.WrapNamespaceBodyWithEmptyLines == FormatStyle::WNBWELS_Never)
+ Newlines = 1;
+ else if (!Line.startsWithNamespace())
+ Newlines = std::max(Newlines, 2u);
+ }
+ // Modify empty lines before TT_NamespaceRBrace.
+ if (Line.startsWith(TT_NamespaceRBrace)) {
+ if (Style.WrapNamespaceBodyWithEmptyLines == FormatStyle::WNBWELS_Never)
+ Newlines = 1;
+ else if (!PreviousLine->startsWith(TT_NamespaceRBrace))
+ Newlines = std::max(Newlines, 2u);
+ }
+
----------------
owenca wrote:
```suggestion
}
```
The missing '}' caused the compilation to fail.
https://github.com/llvm/llvm-project/pull/106145
More information about the cfe-commits
mailing list