[PATCH] D75220: [clang-tidy] RenamerClangTidy now correctly renames `using namespace` decls
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 18 15:14:29 PDT 2020
njames93 updated this revision to Diff 251190.
njames93 added a comment.
- Fixed comment nit
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75220/new/
https://reviews.llvm.org/D75220
Files:
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -527,3 +527,8 @@
// 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;
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -272,6 +272,11 @@
}
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75220.251190.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200318/d8a006a5/attachment.bin>
More information about the cfe-commits
mailing list