Issue 90966
Summary [clang-format] RemoveParentheses option breaks fold expressions
Labels clang-format
Assignees
Reporter A-Kovalev-Playrix
    With any option except Leave clang-format breaks code with fold expressions. 

Test example:
```
template<class... TArgs>
struct TestParams {
  template<class... TArgsLocal>
  bool Test(TArgsLocal&&... args) noexcept {
    static_assert((... && std::is_convertible_v<TArgsLocal, TArgs>));

    if constexpr ((... && std::is_convertible_v<TArgsLocal, TArgs>)) {
      // something
    }

    return (... && std::is_convertible_v<TArgsLocal, TArgs>);
  }
};
```
after reformat it with option RemoveParentheses equals to ReturnStatement it will look like this:
```
template<class... TArgs>
struct TestParams
{
  template<class... TArgsLocal>
  bool Test(TArgsLocal&&... args) noexcept
  {
    static_assert(... && std::is_convertible_v<TArgsLocal, TArgs>);

    if constexpr (... && std::is_convertible_v<TArgsLocal, TArgs>) {
      // something
 }

    return ... && std::is_convertible_v<TArgsLocal, TArgs>;
 }
};
```

In result the code becomes invalid as fold expressions should always have parentheses around them. It would be great to have support of fold expressions and avoid removal of extra parentheses.

Tested it on clang-format version 18.1.5
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to