llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang-tidy][request] Flag use of empty init list in function call

Open chrchr-github opened this issue 2 years ago • 3 comments

Readibility can be improved by specifying the type or using a literal. Maybe there could be an option to only consider fundamental types.

#include <vector>

void f(const std::vector<int>& v, bool b, int i, double d);
void g() {
    f({}, {}, {}, {});
    f(std::vector<int>(), false, 0, 0.0);
}

https://godbolt.org/z/Pfo3YYWGc

chrchr-github avatar Apr 23 '24 12:04 chrchr-github

for built-in types, i like it.... For non-trivial types, there could be an option.

PiotrZSL avatar Apr 23 '24 13:04 PiotrZSL

For both fundamental types and user-defined types in the empty initializer list, the behavior and interpretation depend on type's constructor or initialization rules.

idler66 avatar May 07 '24 09:05 idler66

can I work on this?

joeamroo avatar Oct 20 '25 09:10 joeamroo