[PATCH] D75220: [clang-tidy] RenamerClangTidy now correctly renames decls

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 16:18:51 PST 2020


njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, JonasToth, hokein, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 updated this revision to Diff 246853.
njames93 added a comment.

- Remove unnecessary include


Fixes readability-identifier-naming doesn't rename using namespace correctly. <https://bugs.llvm.org/show_bug.cgi?id=45039>


Repository:
  rG LLVM Github Monorepo

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,13 @@
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs<NamedDecl>("decl")) {
+
+    // fix using namespace decls
+    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.246853.patch
Type: text/x-patch
Size: 1288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200227/3ec09000/attachment.bin>


More information about the cfe-commits mailing list