[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 22 17:59:22 PDT 2024


================
@@ -361,9 +361,18 @@ 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)) {
+        if (unsigned result = tryMergeNamespace(I, E, Limit))
+          return result;
----------------
owenca wrote:

```suggestion
        unsigned 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