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

Galen Elias via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 25 15:54:59 PDT 2024


================
@@ -616,6 +626,62 @@ class LineJoiner {
     return 1;
   }
 
+  unsigned tryMergeNamespace(SmallVectorImpl<AnnotatedLine *>::const_iterator I,
+                             SmallVectorImpl<AnnotatedLine *>::const_iterator E,
+                             unsigned Limit) {
+    if (Limit == 0)
----------------
galenelias wrote:

We can't take an `int` here, because when ColumnLimit = 0, then the calling code passes in `UINT_MAX` which would then underflow the int.  I could technically take a int64_t, but in general it seems like the style is to pre-check for underflow before doing subtraction, which is the approach here (although it's a little indirect).  See below.

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


More information about the cfe-commits mailing list