[clang-tidy] Add new check to find redundant explicit constructor calls in function declarations
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
We already have [check](https://clang.llvm.org/extra/clang-tidy/checks/modernize/return-braced-init-list.html) to catch these cases:
```cpp
Foo bar() {
Baz baz;
return Foo(baz);
}
// transforms to:
Foo bar() {
Baz baz;
return {baz};
}
```
But we do not have check to catch these, see https://godbolt.org/z/1bdK7MG67:
```cpp
void bar(Baz baz = Baz()) {
}
// transforms to:
void bar(Baz baz = {}) {
}
```
Contributor guide
Research direction
Start by reading the existing modernize/return-braced-init-list clang-tidy check and the Godbolt example linked in the issue. Trace how that check identifies explicit constructor calls, then determine how function declarations with default arguments should be handled. Done means the new check detects the shown pattern and transforms `Baz()` to `{}` without changing other declarations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100