[clang] [clang-format] Don't remove parentheses of fold expressions (PR #91045)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat May 4 23:58:03 PDT 2024


owenca wrote:

> I wouldn't worry too much about this, but, pedantically, you can be sure it's a fold expression if the ellipsis is followed with or preceded by an operator
> 
> https://eel.is/c++draft/expr.prim.fold#nt:fold-operator

I had thought of that but decided not to bother. From https://en.cppreference.com/w/cpp/language/fold:
```
op - any of the following 32 binary operators: + - * / % ^ & | = < > << >> += -= *= /= %= ^= &= |= <<= >>= == != <= >= && || , .* ->*
```
Because `<` and `>` are on the list, we still wouldn't be able to tell if `...>` is part of a fold expression. Also, I don't like the overhead of up to 32 comparisons.

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


More information about the cfe-commits mailing list