[clang-tools-extra] [clang-tidy] Rename 'google-build-namespaces' check to 'misc-anonymous-namespace-in-header' and keep initial as alias. (PR #170986)
Ondřej Štorc via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 7 23:24:25 PST 2025
https://github.com/ostorc updated https://github.com/llvm/llvm-project/pull/170986
>From 69583481e4bb1df710dd8596ac2eea74219ba00c Mon Sep 17 00:00:00 2001
From: Ondrej Storc <storcond at fit.cvut.cz>
Date: Sat, 6 Dec 2025 17:00:45 +0100
Subject: [PATCH 1/5] [clang-tidy] Rename 'google-build-namespaces' check to
'misc-anonymous-namespace-in-header'
---
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp | 4 ++--
.../clang-tidy/fuchsia/FuchsiaTidyModule.cpp | 4 ++--
clang-tools-extra/clang-tidy/google/CMakeLists.txt | 1 -
.../clang-tidy/google/GoogleTidyModule.cpp | 4 ++--
clang-tools-extra/clang-tidy/misc/CMakeLists.txt | 1 +
clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | 3 +++
.../UnnamedNamespaceInHeaderCheck.cpp | 4 ++--
.../{google => misc}/UnnamedNamespaceInHeaderCheck.h | 12 ++++++------
8 files changed, 18 insertions(+), 15 deletions(-)
rename clang-tools-extra/clang-tidy/{google => misc}/UnnamedNamespaceInHeaderCheck.cpp (94%)
rename clang-tools-extra/clang-tidy/{google => misc}/UnnamedNamespaceInHeaderCheck.h (74%)
diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index 16d4be9802cc6..bc570cd59450e 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -31,12 +31,12 @@
#include "../bugprone/UnsafeFunctionsCheck.h"
#include "../bugprone/UnusedReturnValueCheck.h"
#include "../concurrency/ThreadCanceltypeAsynchronousCheck.h"
-#include "../google/UnnamedNamespaceInHeaderCheck.h"
#include "../misc/NewDeleteOverloadsCheck.h"
#include "../misc/NonCopyableObjectsCheck.h"
#include "../misc/PredictableRandCheck.h"
#include "../misc/StaticAssertCheck.h"
#include "../misc/ThrowByValueCatchByReferenceCheck.h"
+#include "../misc/UnnamedNamespaceInHeaderCheck.h"
#include "../modernize/AvoidSetjmpLongjmpCheck.h"
#include "../modernize/AvoidVariadicFunctionsCheck.h"
#include "../performance/MoveConstructorInitCheck.h"
@@ -253,7 +253,7 @@ class CERTModule : public ClangTidyModule {
"cert-dcl54-cpp");
CheckFactories.registerCheck<bugprone::StdNamespaceModificationCheck>(
"cert-dcl58-cpp");
- CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
+ CheckFactories.registerCheck<misc::build::UnnamedNamespaceInHeaderCheck>(
"cert-dcl59-cpp");
// ERR
CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
diff --git a/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp b/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
index c62c43f0c42a3..20d86b6cf38ab 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
@@ -9,7 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
-#include "../google/UnnamedNamespaceInHeaderCheck.h"
+#include "../misc/UnnamedNamespaceInHeaderCheck.h"
#include "DefaultArgumentsCallsCheck.h"
#include "DefaultArgumentsDeclarationsCheck.h"
#include "MultipleInheritanceCheck.h"
@@ -32,7 +32,7 @@ class FuchsiaModule : public ClangTidyModule {
"fuchsia-default-arguments-calls");
CheckFactories.registerCheck<DefaultArgumentsDeclarationsCheck>(
"fuchsia-default-arguments-declarations");
- CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
+ CheckFactories.registerCheck<misc::build::UnnamedNamespaceInHeaderCheck>(
"fuchsia-header-anon-namespaces");
CheckFactories.registerCheck<MultipleInheritanceCheck>(
"fuchsia-multiple-inheritance");
diff --git a/clang-tools-extra/clang-tidy/google/CMakeLists.txt b/clang-tools-extra/clang-tidy/google/CMakeLists.txt
index 1d4229ebb7b09..4335cf4aa11f9 100644
--- a/clang-tools-extra/clang-tidy/google/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/google/CMakeLists.txt
@@ -19,7 +19,6 @@ add_clang_library(clangTidyGoogleModule STATIC
IntegerTypesCheck.cpp
OverloadedUnaryAndCheck.cpp
TodoCommentCheck.cpp
- UnnamedNamespaceInHeaderCheck.cpp
UpgradeGoogletestCaseCheck.cpp
UsingNamespaceDirectiveCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp b/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
index aff8b45ff2f74..8749cea94c899 100644
--- a/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
@@ -9,6 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
+#include "../misc/UnnamedNamespaceInHeaderCheck.h"
#include "../readability/BracesAroundStatementsCheck.h"
#include "../readability/FunctionSizeCheck.h"
#include "../readability/NamespaceCommentCheck.h"
@@ -26,7 +27,6 @@
#include "IntegerTypesCheck.h"
#include "OverloadedUnaryAndCheck.h"
#include "TodoCommentCheck.h"
-#include "UnnamedNamespaceInHeaderCheck.h"
#include "UpgradeGoogletestCaseCheck.h"
#include "UsingNamespaceDirectiveCheck.h"
@@ -40,7 +40,7 @@ class GoogleModule : public ClangTidyModule {
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<build::ExplicitMakePairCheck>(
"google-build-explicit-make-pair");
- CheckFactories.registerCheck<build::UnnamedNamespaceInHeaderCheck>(
+ CheckFactories.registerCheck<misc::build::UnnamedNamespaceInHeaderCheck>(
"google-build-namespaces");
CheckFactories.registerCheck<build::UsingNamespaceDirectiveCheck>(
"google-build-using-namespace");
diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index e8705aada3f22..94cede12da4d5 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -39,6 +39,7 @@ add_clang_library(clangTidyMiscModule STATIC
ThrowByValueCatchByReferenceCheck.cpp
UnconventionalAssignOperatorCheck.cpp
UniqueptrResetReleaseCheck.cpp
+ UnnamedNamespaceInHeaderCheck.cpp
UnusedAliasDeclsCheck.cpp
UnusedParametersCheck.cpp
UnusedUsingDeclsCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
index 03f25775de0bf..157411e9ac36b 100644
--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -29,6 +29,7 @@
#include "ThrowByValueCatchByReferenceCheck.h"
#include "UnconventionalAssignOperatorCheck.h"
#include "UniqueptrResetReleaseCheck.h"
+#include "UnnamedNamespaceInHeaderCheck.h"
#include "UnusedAliasDeclsCheck.h"
#include "UnusedParametersCheck.h"
#include "UnusedUsingDeclsCheck.h"
@@ -41,6 +42,8 @@ namespace misc {
class MiscModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+ CheckFactories.registerCheck<build::UnnamedNamespaceInHeaderCheck>(
+ "misc-anonymous-namespace-in-header");
CheckFactories.registerCheck<ConfusableIdentifierCheck>(
"misc-confusable-identifiers");
CheckFactories.registerCheck<ConstCorrectnessCheck>(
diff --git a/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnnamedNamespaceInHeaderCheck.cpp
similarity index 94%
rename from clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
rename to clang-tools-extra/clang-tidy/misc/UnnamedNamespaceInHeaderCheck.cpp
index 054bdc8d1230e..6bba314b5d947 100644
--- a/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnnamedNamespaceInHeaderCheck.cpp
@@ -12,7 +12,7 @@
using namespace clang::ast_matchers;
-namespace clang::tidy::google::build {
+namespace clang::tidy::misc::build {
UnnamedNamespaceInHeaderCheck::UnnamedNamespaceInHeaderCheck(
StringRef Name, ClangTidyContext *Context)
@@ -37,4 +37,4 @@ void UnnamedNamespaceInHeaderCheck::check(
diag(Loc, "do not use unnamed namespaces in header files");
}
-} // namespace clang::tidy::google::build
+} // namespace clang::tidy::misc::build
diff --git a/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h b/clang-tools-extra/clang-tidy/misc/UnnamedNamespaceInHeaderCheck.h
similarity index 74%
rename from clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
rename to clang-tools-extra/clang-tidy/misc/UnnamedNamespaceInHeaderCheck.h
index 78e8127a5a342..0225922083d0c 100644
--- a/clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/UnnamedNamespaceInHeaderCheck.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UNNAMEDNAMESPACEINHEADERCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UNNAMEDNAMESPACEINHEADERCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNNAMEDNAMESPACEINHEADERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNNAMEDNAMESPACEINHEADERCHECK_H
#include "../ClangTidyCheck.h"
#include "../utils/FileExtensionsUtils.h"
-namespace clang::tidy::google::build {
+namespace clang::tidy::misc::build {
/// Finds anonymous namespaces in headers.
///
@@ -21,7 +21,7 @@ namespace clang::tidy::google::build {
/// Corresponding cpplint.py check name: 'build/namespaces'.
///
/// For the user-facing documentation see:
-/// https://clang.llvm.org/extra/clang-tidy/checks/google/build-namespaces.html
+/// https://clang.llvm.org/extra/clang-tidy/checks/misc/build-namespaces.html
class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck {
public:
UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context);
@@ -35,6 +35,6 @@ class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck {
FileExtensionsSet HeaderFileExtensions;
};
-} // namespace clang::tidy::google::build
+} // namespace clang::tidy::misc::build
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UNNAMEDNAMESPACEINHEADERCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNNAMEDNAMESPACEINHEADERCHECK_H
>From 84388d2da3ef1e8b0e619d33800af5ce0f9c08e5 Mon Sep 17 00:00:00 2001
From: Ondrej Storc <storcond at fit.cvut.cz>
Date: Sat, 6 Dec 2025 17:10:09 +0100
Subject: [PATCH 2/5] [clang-tidy] Update references to
'google-build-namespaces' to 'misc-anonymous-namespace-in-header' and create
new documentation for the latter
---
.../docs/clang-tidy/checks/cert/dcl59-cpp.rst | 4 ++--
.../checks/fuchsia/header-anon-namespaces.rst | 4 ++--
.../clang-tidy/checks/google/build-namespaces.rst | 13 +++++--------
clang-tools-extra/docs/clang-tidy/checks/list.rst | 7 ++++---
.../checks/misc/anonymous-namespace-in-header.rst | 14 ++++++++++++++
5 files changed, 27 insertions(+), 15 deletions(-)
create mode 100644 clang-tools-extra/docs/clang-tidy/checks/misc/anonymous-namespace-in-header.rst
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/dcl59-cpp.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/dcl59-cpp.rst
index 027d2eca09195..ee66ec92f8478 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/dcl59-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/dcl59-cpp.rst
@@ -1,10 +1,10 @@
.. title:: clang-tidy - cert-dcl59-cpp
.. meta::
- :http-equiv=refresh: 5;URL=../google/build-namespaces.html
+ :http-equiv=refresh: 5;URL=../misc/anonymous-namespace-in-header.html
cert-dcl59-cpp
==============
The `cert-dcl59-cpp` check is an alias, please see
-:doc:`google-build-namespaces <../google/build-namespaces>`
+:doc:`misc-anonymous-namespace-in-header <../misc/anonymous-namespace-in-header>`
for more information.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/fuchsia/header-anon-namespaces.rst b/clang-tools-extra/docs/clang-tidy/checks/fuchsia/header-anon-namespaces.rst
index a92f3f411c031..44cd73259c2fd 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/fuchsia/header-anon-namespaces.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/fuchsia/header-anon-namespaces.rst
@@ -1,10 +1,10 @@
.. title:: clang-tidy - fuchsia-header-anon-namespaces
.. meta::
- :http-equiv=refresh: 5;URL=../google/build-namespaces.html
+ :http-equiv=refresh: 5;URL=../misc/anonymous-namespace-in-header.html
fuchsia-header-anon-namespaces
==============================
The fuchsia-header-anon-namespaces check is an alias, please see
-:doc:`google-build-namespace <../google/build-namespaces>`
+:doc:`misc-anonymous-namespace-in-header <../misc/anonymous-namespace-in-header>`
for more information.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst b/clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst
index b421d992d63a6..26a0765221ce6 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst
@@ -1,13 +1,10 @@
.. title:: clang-tidy - google-build-namespaces
+.. meta::
+ :http-equiv=refresh: 5;URL=../misc/anonymous-namespace-in-header.html
google-build-namespaces
=======================
-`cert-dcl59-cpp` redirects here as an alias for this check.
-`fuchsia-header-anon-namespaces` redirects here as an alias for this check.
-
-Finds anonymous namespaces in headers.
-
-https://google.github.io/styleguide/cppguide.html#Namespaces
-
-Corresponding cpplint.py check name: `build/namespaces`.
+The `google-build-namespaces` check is an alias, please see
+:doc:`misc-anonymous-namespace-in-header <../misc/anonymous-namespace-in-header>`
+for more information.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 8bb112f3d1832..295a6b07474e7 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -229,7 +229,6 @@ Clang-Tidy Checks
:doc:`fuchsia-trailing-return <fuchsia/trailing-return>`,
:doc:`fuchsia-virtual-inheritance <fuchsia/virtual-inheritance>`,
:doc:`google-build-explicit-make-pair <google/build-explicit-make-pair>`,
- :doc:`google-build-namespaces <google/build-namespaces>`,
:doc:`google-build-using-namespace <google/build-using-namespace>`,
:doc:`google-default-arguments <google/default-arguments>`,
:doc:`google-explicit-constructor <google/explicit-constructor>`, "Yes"
@@ -264,6 +263,7 @@ Clang-Tidy Checks
:doc:`llvmlibc-implementation-in-namespace <llvmlibc/implementation-in-namespace>`,
:doc:`llvmlibc-inline-function-decl <llvmlibc/inline-function-decl>`, "Yes"
:doc:`llvmlibc-restrict-system-libc-headers <llvmlibc/restrict-system-libc-headers>`, "Yes"
+ :doc:`misc-anonymous-namespace-in-header <misc/anonymous-namespace-in-header>`,
:doc:`misc-confusable-identifiers <misc/confusable-identifiers>`,
:doc:`misc-const-correctness <misc/const-correctness>`, "Yes"
:doc:`misc-coroutine-hostile-raii <misc/coroutine-hostile-raii>`,
@@ -446,7 +446,7 @@ Check aliases
:doc:`cert-dcl51-cpp <cert/dcl51-cpp>`, :doc:`bugprone-reserved-identifier <bugprone/reserved-identifier>`, "Yes"
:doc:`cert-dcl54-cpp <cert/dcl54-cpp>`, :doc:`misc-new-delete-overloads <misc/new-delete-overloads>`,
:doc:`cert-dcl58-cpp <cert/dcl58-cpp>`, :doc:`bugprone-std-namespace-modification <bugprone/std-namespace-modification>`,
- :doc:`cert-dcl59-cpp <cert/dcl59-cpp>`, :doc:`google-build-namespaces <google/build-namespaces>`,
+ :doc:`cert-dcl59-cpp <cert/dcl59-cpp>`, :doc:`misc-anonymous-namespace-in-header <misc/anonymous-namespace-in-header>`,
:doc:`cert-env33-c <cert/env33-c>`, :doc:`bugprone-command-processor <bugprone/command-processor>`,
:doc:`cert-err09-cpp <cert/err09-cpp>`, :doc:`misc-throw-by-value-catch-by-reference <misc/throw-by-value-catch-by-reference>`,
:doc:`cert-err34-c <cert/err34-c>`, :doc:`bugprone-unchecked-string-to-number-conversion <bugprone/unchecked-string-to-number-conversion>`,
@@ -583,7 +583,8 @@ Check aliases
:doc:`cppcoreguidelines-noexcept-swap <cppcoreguidelines/noexcept-swap>`, :doc:`performance-noexcept-swap <performance/noexcept-swap>`, "Yes"
:doc:`cppcoreguidelines-non-private-member-variables-in-classes <cppcoreguidelines/non-private-member-variables-in-classes>`, :doc:`misc-non-private-member-variables-in-classes <misc/non-private-member-variables-in-classes>`,
:doc:`cppcoreguidelines-use-default-member-init <cppcoreguidelines/use-default-member-init>`, :doc:`modernize-use-default-member-init <modernize/use-default-member-init>`, "Yes"
- :doc:`fuchsia-header-anon-namespaces <fuchsia/header-anon-namespaces>`, :doc:`google-build-namespaces <google/build-namespaces>`,
+ :doc:`fuchsia-header-anon-namespaces <fuchsia/header-anon-namespaces>`, :doc:`misc-anonymous-namespace-in-header <misc/anonymous-namespace-in-header>`,
+ :doc:`google-build-namespaces <google/build-namespaces>`, :doc:`misc-anonymous-namespace-in-header <misc/anonymous-namespace-in-header>`,
:doc:`google-readability-braces-around-statements <google/readability-braces-around-statements>`, :doc:`readability-braces-around-statements <readability/braces-around-statements>`, "Yes"
:doc:`google-readability-function-size <google/readability-function-size>`, :doc:`readability-function-size <readability/function-size>`,
:doc:`google-readability-namespace-comments <google/readability-namespace-comments>`, :doc:`llvm-namespace-comment <llvm/namespace-comment>`,
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/anonymous-namespace-in-header.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/anonymous-namespace-in-header.rst
new file mode 100644
index 0000000000000..796642adc095f
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/anonymous-namespace-in-header.rst
@@ -0,0 +1,14 @@
+.. title:: clang-tidy - anonymous-namespace-in-header
+
+anonymous-namespace-in-header
+=============================
+
+`cert-dcl59-cpp` redirects here as an alias for this check.
+`fuchsia-header-anon-namespaces` redirects here as an alias for this check.
+`google-build-namespaces` redirects here as an alias for this check.
+
+Finds anonymous namespaces in headers.
+
+https://google.github.io/styleguide/cppguide.html#Namespaces
+
+Corresponding cpplint.py check name: `build/namespaces`.
>From 07e1f950dbff7d1e16b9d9a80911cba61bd87814 Mon Sep 17 00:00:00 2001
From: Ondrej Storc <storcond at fit.cvut.cz>
Date: Sat, 6 Dec 2025 17:15:36 +0100
Subject: [PATCH 3/5] [clang-tidy] Replace 'google-build-namespaces' checks
with 'misc-anonymous-namespace-in-header' in tests and move it to
coresponding place
---
.../test/clang-tidy/checkers/google/namespaces.cpp | 4 ----
.../google-namespaces.h => misc/Inputs/anon-namespaces.h} | 0
.../test/clang-tidy/checkers/misc/namespaces.cpp | 3 +++
3 files changed, 3 insertions(+), 4 deletions(-)
rename clang-tools-extra/test/clang-tidy/checkers/{google/Inputs/google-namespaces.h => misc/Inputs/anon-namespaces.h} (100%)
create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/namespaces.cpp
diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp b/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp
index 9bda3c0451b39..d830146fe1ff1 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp
@@ -1,7 +1,3 @@
-// RUN: clang-tidy %s -checks='-*,google-build-namespaces,google-build-using-namespace' -header-filter='.*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
-#include "Inputs/google-namespaces.h"
-// CHECK: warning: do not use unnamed namespaces in header files [google-build-namespaces]
-
using namespace spaaaace;
// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/Inputs/google-namespaces.h b/clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/anon-namespaces.h
similarity index 100%
rename from clang-tools-extra/test/clang-tidy/checkers/google/Inputs/google-namespaces.h
rename to clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/anon-namespaces.h
diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/namespaces.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/namespaces.cpp
new file mode 100644
index 0000000000000..d01547bfde8ce
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/namespaces.cpp
@@ -0,0 +1,3 @@
+// RUN: clang-tidy %s -checks='-*,misc-anonymous-namespace-in-header,google-build-using-namespace' -header-filter='.*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
+#include "Inputs/anon-namespaces.h"
+// CHECK: warning: do not use unnamed namespaces in header files [misc-anonymous-namespace-in-header]
>From a33d504c1bda6d9483fc127a6281a5698d7f16cb Mon Sep 17 00:00:00 2001
From: Ondrej Storc <storcond at fit.cvut.cz>
Date: Sat, 6 Dec 2025 17:19:54 +0100
Subject: [PATCH 4/5] [clang-tidy] Update release notes
---
clang-tools-extra/docs/ReleaseNotes.rst | 5 +++++
.../test/clang-tidy/checkers/google/namespaces.cpp | 3 +++
2 files changed, 8 insertions(+)
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 42160fa9cb51c..9d2ed11a4044a 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -328,6 +328,11 @@ New check aliases
<clang-tidy/checks/bugprone/copy-constructor-mutates-argument>`
keeping initial check as an alias to the new one.
+- Renamed :doc:`google-build-namespaces` to
+ :doc:`misc-anonymous-namespace-in-header
+ <clang-tidy/checks/misc/anonymous-namespace-in-header>`
+ keeping initial check as an alias to the new one.
+
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp b/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp
index d830146fe1ff1..b0b278001d11d 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp
@@ -1,3 +1,6 @@
+// RUN: clang-tidy %s -checks='-*,google-build-namespaces,google-build-using-namespace' -header-filter='.*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
+#include "../misc/Inputs/anon-namespaces.h"
+// CHECK: warning: do not use unnamed namespaces in header files [google-build-namespaces]
using namespace spaaaace;
// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
>From b3599aa2e76eee4e820423ebe96c93ddb0f6f266 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0torc?= <storc.1998 at gmail.com>
Date: Mon, 8 Dec 2025 08:24:15 +0100
Subject: [PATCH 5/5] Update clang-tools-extra/docs/ReleaseNotes.rst
Co-authored-by: mitchell <mitchell.xu2 at gmail.com>
---
clang-tools-extra/docs/ReleaseNotes.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 9d2ed11a4044a..89c012630bcc0 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -328,7 +328,7 @@ New check aliases
<clang-tidy/checks/bugprone/copy-constructor-mutates-argument>`
keeping initial check as an alias to the new one.
-- Renamed :doc:`google-build-namespaces` to
+- Renamed :doc:`google-build-namespaces <clang-tidy/checks/google/build-namespaces>` to
:doc:`misc-anonymous-namespace-in-header
<clang-tidy/checks/misc/anonymous-namespace-in-header>`
keeping initial check as an alias to the new one.
More information about the cfe-commits
mailing list