[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 14 08:52:43 PST 2023


carlosgalvezp created this revision.
Herald added a subscriber: xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
carlosgalvezp requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141769

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py


Index: clang-tools-extra/clang-tidy/rename_check.py
===================================================================
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -308,8 +308,13 @@
     for filename in check_implementation_files:
       # Move check implementation to the directory of the new module.
       filename = fileRename(filename, old_module_path, new_module_path)
+      # TODO: remove below replacement when all clang-tidy checks have been
+      # updated with C++17 nested namespaces.
       replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
                          'namespace ' + new_namespace)
+      replaceInFileRegex(filename,
+                         'namespace clang::tidy::' + old_module + '[^ \n]*',
+                         'namespace clang::tidy::' + new_namespace)
 
   if (args.old_check_name == args.new_check_name):
     return
Index: clang-tools-extra/clang-tidy/add_new_check.py
===================================================================
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -77,9 +77,7 @@
 
 #include "../ClangTidyCheck.h"
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 /// FIXME: Write a short description.
 ///
@@ -93,9 +91,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 
 #endif // %(header_guard)s
 """ % {'header_guard': header_guard,
@@ -129,9 +125,7 @@
 
 using namespace clang::ast_matchers;
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 void %(check_name)s::registerMatchers(MatchFinder *Finder) {
   // FIXME: Add matchers.
@@ -149,9 +143,7 @@
       << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 """ % {'check_name': check_name_camel,
        'module': module,
        'namespace': namespace})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141769.489270.patch
Type: text/x-patch
Size: 2222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230114/6c587830/attachment.bin>


More information about the cfe-commits mailing list