[clang] [clang-format] Add SpacesInParensOption for attributes and filtering for repeated parens (PR #77522)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 20 23:29:01 PST 2024


owenca wrote:

> The code is [self-hosted](https://git.rtems.org/rtems/) and [mirrored on GitHub](https://github.com/RTEMS/rtems) with a [documented style guide](https://docs.rtems.org/branches/master/eng/coding-formatting.html). In addition, I have been and will continue to be willing to provide bug fix and other maintenance support to clang-format based on the changes submitted to support these style needs.
> 
> At the moment, I need to satisfy a particular style rule that requires me to add spaces inside of conditional and compound expressions.

It seems the RTEMS style guide you linked above doesn't have any examples for conditional expressions and compound expressions, and by _conditional expressions_ I assume it means conditionals of control statements rather than ternary [conditional expressions](https://www.ibm.com/docs/en/zos/3.1.0?topic=operators-conditional-expressions).

Would `__attribute__((noreturn))`, `if ((i = j))`, `decltype((x))`, and `while (((i + 1) * j - 2) * k > 3)` be formatted as `__attribute__(( noreturn ))`, `if (( i = j ))`, `decltype(( x ))`, and `while ( ( ( i + 1 ) * j - 2 ) * k > 3 )`, respectively?

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


More information about the cfe-commits mailing list