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

Emilia Kond via cfe-commits cfe-commits at lists.llvm.org
Sat May 4 02:28:52 PDT 2024


https://github.com/rymiel approved this pull request.

I can definitely think of cases where an expression might contain `...` and still have redundant parentheses, i.e. if the ellipsis isn't part of a fold expression

For example:
```c++
template <typename... N>
std::tuple<N...> foo() {
    return (std::tuple<N...>{});
}
```
Those parens around the returned expression are redundant, but they would now no longer be removed.

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

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


More information about the cfe-commits mailing list