forked from OSchip/llvm-project
[clang-tidy] RenamerClangTidy now correctly renames `using namespace` decls
Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=45039 | readability-identifier-naming doesn't rename using namespace correctly. ]] Reviewers: aaron.ballman, gribozavr2, JonasToth, hokein, alexfh Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75220
This commit is contained in:
parent
5ffb30fd6c
commit
1365ab4b63
|
@ -272,6 +272,11 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
|
||||
if (const auto *Decl = Result.Nodes.getNodeAs<NamedDecl>("decl")) {
|
||||
// Fix using namespace declarations.
|
||||
if (const auto *UsingNS = dyn_cast<UsingDirectiveDecl>(Decl))
|
||||
addUsage(NamingCheckFailures, UsingNS->getNominatedNamespaceAsWritten(),
|
||||
UsingNS->getIdentLocation());
|
||||
|
||||
if (!Decl->getIdentifier() || Decl->getName().empty() || Decl->isImplicit())
|
||||
return;
|
||||
|
||||
|
|
|
@ -527,3 +527,8 @@ void MyPoiterFunction(int * p_normal_pointer, int * const constant_ptr){
|
|||
// CHECK-FIXES: {{^}} int * const lc_PointerB = nullptr;{{$}}
|
||||
}
|
||||
|
||||
using namespace FOO_NS;
|
||||
// CHECK-FIXES: {{^}}using namespace foo_ns;
|
||||
|
||||
using namespace FOO_NS::InlineNamespace;
|
||||
// CHECK-FIXES: {{^}}using namespace foo_ns::inline_namespace;
|
||||
|
|
Loading…
Reference in New Issue