diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/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}) diff --git a/clang-tools-extra/clang-tidy/rename_check.py b/clang-tools-extra/clang-tidy/rename_check.py --- a/clang-tools-extra/clang-tidy/rename_check.py +++ b/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 diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -106,6 +106,8 @@ which is no longer in use. The option will be fully removed in :program:`clang-tidy` version 18. +- Use C++17 nested namespaces in `add_new_check.py` and `rename_check.py`. + New checks ^^^^^^^^^^