[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 28 01:29:21 PST 2024
================
@@ -361,9 +361,19 @@ class LineJoiner {
const auto *FirstNonComment = TheLine->getFirstNonComment();
if (!FirstNonComment)
return 0;
+
// FIXME: There are probably cases where we should use FirstNonComment
// instead of TheLine->First.
+ if (TheLine->Last->is(tok::l_brace)) {
+ if (Style.AllowShortNamespacesOnASingleLine &&
+ TheLine->First->is(tok::kw_namespace)) {
+ unsigned result = tryMergeNamespace(I, E, Limit);
+ if (result > 0)
+ return result;
+ }
+ }
----------------
owenca wrote:
```suggestion
if (Style.AllowShortNamespacesOnASingleLine &&
TheLine->First->is(tok::kw_namespace) &&
TheLine->Last->is(tok::l_brace)) {
const auto result = tryMergeNamespace(I, E, Limit);
if (result > 0)
return result;
}
```
https://github.com/llvm/llvm-project/pull/105597
More information about the cfe-commits
mailing list