[clang-tools-extra] [clang-tidy] Deprecate 'zircon' module (PR #162012)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 8 14:55:42 PDT 2025
https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/162012
>From 8aeff4dc2c430b24a249f08f9c863fde35b8ad31 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sun, 5 Oct 2025 16:01:45 +0300
Subject: [PATCH 1/3] [clang-tidy] Deprecate 'zircon' module
---
.../clang-tidy/fuchsia/CMakeLists.txt | 1 +
.../clang-tidy/fuchsia/FuchsiaTidyModule.cpp | 3 ++
.../TemporaryObjectsCheck.cpp | 4 +-
.../TemporaryObjectsCheck.h | 12 ++---
.../clang-tidy/zircon/CMakeLists.txt | 2 +-
.../clang-tidy/zircon/ZirconTidyModule.cpp | 8 ++-
clang-tools-extra/docs/ReleaseNotes.rst | 8 +++
.../checks/fuchsia/temporary-objects.rst | 53 +++++++++++++++++++
.../docs/clang-tidy/checks/list.rst | 1 +
.../checks/zircon/temporary-objects.rst | 51 ++----------------
.../{zircon => fuchsia}/temporary-objects.cpp | 4 +-
11 files changed, 84 insertions(+), 63 deletions(-)
rename clang-tools-extra/clang-tidy/{zircon => fuchsia}/TemporaryObjectsCheck.cpp (96%)
rename clang-tools-extra/clang-tidy/{zircon => fuchsia}/TemporaryObjectsCheck.h (76%)
create mode 100644 clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
rename clang-tools-extra/test/clang-tidy/checkers/{zircon => fuchsia}/temporary-objects.cpp (94%)
diff --git a/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt b/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
index c12c281bc5321..c7234098f094a 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
@@ -10,6 +10,7 @@ add_clang_library(clangTidyFuchsiaModule STATIC
MultipleInheritanceCheck.cpp
OverloadedOperatorCheck.cpp
StaticallyConstructedObjectsCheck.cpp
+ TemporaryObjectsCheck.cpp
TrailingReturnCheck.cpp
VirtualInheritanceCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp b/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
index f280a1b07bf39..c62c43f0c42a3 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
@@ -15,6 +15,7 @@
#include "MultipleInheritanceCheck.h"
#include "OverloadedOperatorCheck.h"
#include "StaticallyConstructedObjectsCheck.h"
+#include "TemporaryObjectsCheck.h"
#include "TrailingReturnCheck.h"
#include "VirtualInheritanceCheck.h"
@@ -39,6 +40,8 @@ class FuchsiaModule : public ClangTidyModule {
"fuchsia-overloaded-operator");
CheckFactories.registerCheck<StaticallyConstructedObjectsCheck>(
"fuchsia-statically-constructed-objects");
+ CheckFactories.registerCheck<TemporaryObjectsCheck>(
+ "fuchsia-temporary-objects");
CheckFactories.registerCheck<TrailingReturnCheck>(
"fuchsia-trailing-return");
CheckFactories.registerCheck<VirtualInheritanceCheck>(
diff --git a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.cpp
similarity index 96%
rename from clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
rename to clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.cpp
index 96a36cba827e6..7b910b1021979 100644
--- a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.cpp
@@ -15,7 +15,7 @@
using namespace clang::ast_matchers;
-namespace clang::tidy::zircon {
+namespace clang::tidy::fuchsia {
namespace {
@@ -55,4 +55,4 @@ void TemporaryObjectsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "Names", utils::options::serializeStringList(Names));
}
-} // namespace clang::tidy::zircon
+} // namespace clang::tidy::fuchsia
diff --git a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.h b/clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.h
similarity index 76%
rename from clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.h
rename to clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.h
index ee96fa74affc6..805dae4d577d8 100644
--- a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.h
+++ b/clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.h
@@ -6,19 +6,19 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ZIRCON_TEMPORARYOBJECTSCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ZIRCON_TEMPORARYOBJECTSCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TEMPORARYOBJECTSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TEMPORARYOBJECTSCHECK_H
#include "../ClangTidyCheck.h"
#include "../utils/OptionsUtils.h"
-namespace clang::tidy::zircon {
+namespace clang::tidy::fuchsia {
/// Construction of specific temporary objects in the Zircon kernel is
/// discouraged.
///
/// For the user-facing documentation see:
-/// https://clang.llvm.org/extra/clang-tidy/checks/zircon/temporary-objects.html
+/// https://clang.llvm.org/extra/clang-tidy/checks/fuchsia/temporary-objects.html
class TemporaryObjectsCheck : public ClangTidyCheck {
public:
TemporaryObjectsCheck(StringRef Name, ClangTidyContext *Context)
@@ -35,6 +35,6 @@ class TemporaryObjectsCheck : public ClangTidyCheck {
std::vector<StringRef> Names;
};
-} // namespace clang::tidy::zircon
+} // namespace clang::tidy::fuchsia
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ZIRCON_TEMPORARYOBJECTSCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TEMPORARYOBJECTSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/zircon/CMakeLists.txt b/clang-tools-extra/clang-tidy/zircon/CMakeLists.txt
index e08fe80e730ac..bc4ab1f58c83d 100644
--- a/clang-tools-extra/clang-tidy/zircon/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/zircon/CMakeLists.txt
@@ -4,11 +4,11 @@ set(LLVM_LINK_COMPONENTS
)
add_clang_library(clangTidyZirconModule STATIC
- TemporaryObjectsCheck.cpp
ZirconTidyModule.cpp
LINK_LIBS
clangTidy
+ clangTidyFuchsiaModule
clangTidyUtils
DEPENDS
diff --git a/clang-tools-extra/clang-tidy/zircon/ZirconTidyModule.cpp b/clang-tools-extra/clang-tidy/zircon/ZirconTidyModule.cpp
index 86d7ce4e04e7b..30db5e251001f 100644
--- a/clang-tools-extra/clang-tidy/zircon/ZirconTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/zircon/ZirconTidyModule.cpp
@@ -9,9 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
-#include "TemporaryObjectsCheck.h"
-
-using namespace clang::ast_matchers;
+#include "../fuchsia/TemporaryObjectsCheck.h"
namespace clang::tidy {
namespace zircon {
@@ -20,14 +18,14 @@ namespace zircon {
class ZirconModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
- CheckFactories.registerCheck<TemporaryObjectsCheck>(
+ CheckFactories.registerCheck<fuchsia::TemporaryObjectsCheck>(
"zircon-temporary-objects");
}
};
// Register the ZirconTidyModule using this statically initialized variable.
static ClangTidyModuleRegistry::Add<ZirconModule>
- X("zircon-module", "Adds Zircon kernel checks.");
+ X("zircon-module", "Adds Zircon kernel checks (deprecated in LLVM 24).");
} // namespace zircon
// This anchor is used to force the linker to link in the generated object file
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 62e1987377989..429d3c141ff19 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -49,6 +49,10 @@ Major New Features
Potentially Breaking Changes
----------------------------
+- Deprecated the :program:`clang-tidy` ``zircon`` module. All checks have been
+ moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed
+ in the 24th release.
+
- Removed :program:`clang-tidy`'s global options `IgnoreMacros` and
`StrictMode`, which were documented as deprecated since
:program:`clang-tidy-20`. Users should use the check-specific options of the
@@ -158,6 +162,10 @@ Improvements to clang-tidy
scripts by adding the `-hide-progress` option to suppress progress and
informational messages.
+- Deprecated the :program:`clang-tidy` ``zircon`` module. All checks have been
+ moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed
+ in the 24th release.
+
New checks
^^^^^^^^^^
diff --git a/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst b/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
new file mode 100644
index 0000000000000..f7589997614dc
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
@@ -0,0 +1,53 @@
+.. title:: clang-tidy - fuchsia-temporary-objects
+
+fuchsia-temporary-objects
+=========================
+
+Warns on construction of specific temporary objects in the Zircon kernel.
+If the object should be flagged, the fully qualified type name must be
+explicitly passed to the check.
+
+For example, given the list of classes "Foo" and "NS::Bar", all of the
+following will trigger the warning:
+
+.. code-block:: c++
+
+ Foo();
+ Foo F = Foo();
+ func(Foo());
+
+ namespace NS {
+
+ Bar();
+
+ }
+
+With the same list, the following will not trigger the warning:
+
+.. code-block:: c++
+
+ Foo F; // Non-temporary construction okay
+ Foo F(param); // Non-temporary construction okay
+ Foo *F = new Foo(); // New construction okay
+
+ Bar(); // Not NS::Bar, so okay
+ NS::Bar B; // Non-temporary construction okay
+
+Note that objects must be explicitly specified in order to be flagged,
+and so objects that inherit a specified object will not be flagged.
+
+This check matches temporary objects without regard for inheritance and so a
+prohibited base class type does not similarly prohibit derived class types.
+
+.. code-block:: c++
+
+ class Derived : Foo {} // Derived is not explicitly disallowed
+ Derived(); // and so temporary construction is okay
+
+Options
+-------
+
+.. option:: Names
+
+ A semi-colon-separated list of fully-qualified names of C++ classes that
+ should not be constructed as temporaries. Default is empty.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index f94696d4ef9c7..41391847618ce 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -222,6 +222,7 @@ Clang-Tidy Checks
:doc:`fuchsia-multiple-inheritance <fuchsia/multiple-inheritance>`,
:doc:`fuchsia-overloaded-operator <fuchsia/overloaded-operator>`,
:doc:`fuchsia-statically-constructed-objects <fuchsia/statically-constructed-objects>`,
+ :doc:`fuchsia-temporary-objects <fuchsia/temporary-objects>`,
: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>`,
diff --git a/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst b/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst
index ab1225faa2139..4795af0842c33 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst
@@ -3,51 +3,8 @@
zircon-temporary-objects
========================
-Warns on construction of specific temporary objects in the Zircon kernel.
-If the object should be flagged, If the object should be flagged, the fully
-qualified type name must be explicitly passed to the check.
+.. note::
-For example, given the list of classes "Foo" and "NS::Bar", all of the
-following will trigger the warning:
-
-.. code-block:: c++
-
- Foo();
- Foo F = Foo();
- func(Foo());
-
- namespace NS {
-
- Bar();
-
- }
-
-With the same list, the following will not trigger the warning:
-
-.. code-block:: c++
-
- Foo F; // Non-temporary construction okay
- Foo F(param); // Non-temporary construction okay
- Foo *F = new Foo(); // New construction okay
-
- Bar(); // Not NS::Bar, so okay
- NS::Bar B; // Non-temporary construction okay
-
-Note that objects must be explicitly specified in order to be flagged,
-and so objects that inherit a specified object will not be flagged.
-
-This check matches temporary objects without regard for inheritance and so a
-prohibited base class type does not similarly prohibit derived class types.
-
-.. code-block:: c++
-
- class Derived : Foo {} // Derived is not explicitly disallowed
- Derived(); // and so temporary construction is okay
-
-Options
--------
-
-.. option:: Names
-
- A semi-colon-separated list of fully-qualified names of C++ classes that
- should not be constructed as temporaries. Default is empty.
+ The `zircon-temporary-objects`` check has been deprecated and will be removed
+ in a 24th release. Please use
+ :doc:`fuchsia-temporary-objects <../fuchsia/temporary-objects>` instead.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/zircon/temporary-objects.cpp b/clang-tools-extra/test/clang-tidy/checkers/fuchsia/temporary-objects.cpp
similarity index 94%
rename from clang-tools-extra/test/clang-tidy/checkers/zircon/temporary-objects.cpp
rename to clang-tools-extra/test/clang-tidy/checkers/fuchsia/temporary-objects.cpp
index 678992aa50326..916671eef726f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/zircon/temporary-objects.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/fuchsia/temporary-objects.cpp
@@ -1,5 +1,5 @@
-// RUN: %check_clang_tidy %s zircon-temporary-objects %t -- \
-// RUN: -config="{CheckOptions: {zircon-temporary-objects.Names: 'Foo;NS::Bar'}}" \
+// RUN: %check_clang_tidy %s fuchsia-temporary-objects %t -- \
+// RUN: -config="{CheckOptions: {fuchsia-temporary-objects.Names: 'Foo;NS::Bar'}}" \
// RUN: -header-filter=.*
// Should flag instances of Foo, NS::Bar.
>From 9450651604d6dca5e361c016b3df843bfcbd5f74 Mon Sep 17 00:00:00 2001
From: Baranov Victor <bar.victor.2002 at gmail.com>
Date: Sun, 5 Oct 2025 16:47:15 +0300
Subject: [PATCH 2/3] Update
clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
Co-authored-by: EugeneZelenko <eugene.zelenko at gmail.com>
---
.../docs/clang-tidy/checks/fuchsia/temporary-objects.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst b/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
index f7589997614dc..29005c4dbcc0c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/fuchsia/temporary-objects.rst
@@ -50,4 +50,4 @@ Options
.. option:: Names
A semi-colon-separated list of fully-qualified names of C++ classes that
- should not be constructed as temporaries. Default is empty.
+ should not be constructed as temporaries. Default is empty string.
>From 4a41f1b4ba4fa156f1615ec7b344531dabd59230 Mon Sep 17 00:00:00 2001
From: Baranov Victor <bar.victor.2002 at gmail.com>
Date: Thu, 9 Oct 2025 00:55:34 +0300
Subject: [PATCH 3/3] Fix docs
---
.../docs/clang-tidy/checks/zircon/temporary-objects.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst b/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst
index 4795af0842c33..a27822e14c1f6 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst
@@ -5,6 +5,6 @@ zircon-temporary-objects
.. note::
- The `zircon-temporary-objects`` check has been deprecated and will be removed
- in a 24th release. Please use
+ The `zircon-temporary-objects` check has been deprecated and will be removed
+ in 24th release of LLVM. Please use
:doc:`fuchsia-temporary-objects <../fuchsia/temporary-objects>` instead.
More information about the cfe-commits
mailing list