Open llvmbot opened 14 years ago
A related case:
struct S { void f() const; int n; };
void f() const { n = 0; }
It'd be amazing if clang could suggest adding "S::" to this function definition. This case is arguably easier, since an ill-formed cv-qualifier (or ref-qualifier) on a function definition is a big giveaway that it was meant to be a member function: we can give an error with a fixit here, whereas the namespace case would have to be just a warning (with a fixit in a note).
We can make this check faster (and weed out false positives) by only looking in classes and namespaces for which we've already seen at least one out-of-line function definition in this TU.
It's kind of like -Wmissing-prototypes for C++. It should not apply to templates or member functions.
@llvm/issue-subscribers-clang-tidy
I think this kind of diagnostic makes more sense as a clang-tidy check, since this heavily depends on how your code base looks.
Extended Description
I would like clang to optionally warn me about 'f0' in this:
ddunbar@giles:tmp$ cat t.cpp
ddunbar@giles:tmp$ clang -Wall -c t.cpp ddunbar@giles:tmp$
I almost never care to implement a non-static, undeclared function. I want clang to point out that I am doing this when it can find a 'f0' inside a different namespace. I want a fixit for adding 'foo::'.