Clang-tidy check for fixing over-qualification of namespaces in C++ (original) (raw)
September 18, 2024, 7:52pm 1
Looking for a specific thing that I believe clang-tidy can be successful at - fixing namespace over-qualifications in C++.
Consider this code:
namespace foo::bar {
class ::foo::bar::Baz {
public:
void do(bar::Baz arg);
};
}
This is all correct and valid C++, but it includes a good amount of namespace over-qualifications, whilst in this specific case they are completely not necessary.
The “fixed” version of this would be:
namespace foo::bar {
class Baz {
public:
void do(Baz arg);
};
}
What I am looking for is:
- Any previous discussion on the topic
- Having a good discussion about whether this is something that should be considered and is a valid thing to add into clang-tidy
- Whether it falls into clang-format or clang-tidy area (I think tidy, since it’s not necessarily always ‘correct’ and might be required to extra qualify in a given scope)
- Help/pointer in making this a reality, as in adding a check and auto-fixer for this(edited)
Reminds me of the clang warning -Wextra-qualification.
I wonder if this would even need to be in a clang-tidy check, or if clang itself should just gain this functionality
nlutsenko September 19, 2024, 3:18pm 3
Good pointer, thank you!
That’s right. extra-qualification though (seemingly, based on quick code search and read) only takes care of member function declarations, whilst what I am talking about here is all types and function use.