[clang] [clang-format] Fix wrapping before ##__VA_ARGS__ macro arguments (PR #214105)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 22 03:56:29 PDT 2026


================
@@ -6511,8 +6511,14 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
             !(Right.Next &&
               Right.Next->isOneOf(TT_FunctionDeclarationName, tok::kw_const)));
   }
-  if (Left.is(tok::hashhash) || Right.is(tok::hashhash))
+  // Keep pasted tokens together, except for the GNU comma elision extension,
+  // where the comma is also an argument separator and remains a useful break
+  // point before ##__VA_ARGS__.
+  if ((Left.is(tok::hashhash) || Right.is(tok::hashhash)) &&
----------------
HazardyKnusperkeks wrote:

This is hard to read. Maybe it's simpler to split `Left.is(tok::hashhash)` and `Right.is(tok::hashhash)` into two `if`s?

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


More information about the cfe-commits mailing list