llvm / llvm/llvm-project

[Clang-Format][Feature Request] Add/Remove parentheses of lambda expression/requires expression if there is no function paremeter.

Open
#174,053 1 comment 0 reactions 0 assignees View on GitHub
clang-format enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
// after adding parenthses
[]() { /* body */ };
requires () { /* body */ };

// after removing parentheses
[] { /* body */ };
requires { /* body */ };

[] () [[attr]] { /* body */ }; // should not be affected
// ^ they are not equivalent v
[] [[attr]] { /* body */ };
// ^ they are equivalent v
[] [[attr]] () { /* body */ };

// can remove parentheses only in C++23 (or later) mode
[] /* contains something other than `()` and template parameter list */ { /* body */ };
```

See https://en.cppreference.com/w/cpp/language/lambda.html for detailed syntax.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.