llvm-project
74ea47b6 - [clang-format] Break and align items after trailing-comma __VA_OPT__ (#240902)

Commit
1 day ago
[clang-format] Break and align items after trailing-comma __VA_OPT__ (#240902) When `__VA_OPT__(..., )` (or `__VA_OPT__(,)`) ends with a top-level comma inside an enum, braced list, parameter list, or expression (for example when migrating unnamed variadic macros from the non-standard `, ##__VA_ARGS__` extension to C++20 `__VA_OPT__(__VA_ARGS__, )`), its closing `)` acts as an item separator. Previously, `clang-format` did not recognize the trailing comma inside `__VA_OPT__`, keeping the following item on the same line (or continuation-indenting it after `)`). Classify the closing `)` of a C/C++ `__VA_OPT__` ending in a top-level non-operator comma as `TT_TrailingCommaVaOptRParen` and treat it as a comma separator across token annotation, parameter counting and column layout, bin-packing, continuation indentation, trailing-comma handling, and expression grouping. Before: ```cpp #define DEFINE_PARAMETER_INDICES(...) \ enum ParameterIndices { \ kTarget = -1, \ __VA_OPT__(__VA_ARGS__, ) kNext, \ kParameterCount, \ }; ``` After: ```cpp #define DEFINE_PARAMETER_INDICES(...) \ enum ParameterIndices { \ kTarget = -1, \ __VA_OPT__(__VA_ARGS__, ) \ kNext, \ kParameterCount, \ }; ``` Assisted-by: Gemini
Author
Parents
Loading