Skip to content

Commit 4968035

Browse files
vbvictorEugeneZelenko
authored andcommitted
[clang-tidy] Deprecate 'zircon' module (llvm#162012)
As for [RFC](https://discourse.llvm.org/t/rfc-deprecate-and-remove-zircon-module-moving-its-only-check-to-fuchsia-module/88208/2), deprecate `zircon` module and remove eventually in LLVM-24. --------- Co-authored-by: EugeneZelenko <[email protected]>
1 parent c1618d6 commit 4968035

File tree

11 files changed

+84
-63
lines changed

11 files changed

+84
-63
lines changed

clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_clang_library(clangTidyFuchsiaModule STATIC
1010
MultipleInheritanceCheck.cpp
1111
OverloadedOperatorCheck.cpp
1212
StaticallyConstructedObjectsCheck.cpp
13+
TemporaryObjectsCheck.cpp
1314
TrailingReturnCheck.cpp
1415
VirtualInheritanceCheck.cpp
1516

clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "MultipleInheritanceCheck.h"
1616
#include "OverloadedOperatorCheck.h"
1717
#include "StaticallyConstructedObjectsCheck.h"
18+
#include "TemporaryObjectsCheck.h"
1819
#include "TrailingReturnCheck.h"
1920
#include "VirtualInheritanceCheck.h"
2021

@@ -39,6 +40,8 @@ class FuchsiaModule : public ClangTidyModule {
3940
"fuchsia-overloaded-operator");
4041
CheckFactories.registerCheck<StaticallyConstructedObjectsCheck>(
4142
"fuchsia-statically-constructed-objects");
43+
CheckFactories.registerCheck<TemporaryObjectsCheck>(
44+
"fuchsia-temporary-objects");
4245
CheckFactories.registerCheck<TrailingReturnCheck>(
4346
"fuchsia-trailing-return");
4447
CheckFactories.registerCheck<VirtualInheritanceCheck>(

clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp renamed to clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
using namespace clang::ast_matchers;
1717

18-
namespace clang::tidy::zircon {
18+
namespace clang::tidy::fuchsia {
1919

2020
namespace {
2121

@@ -55,4 +55,4 @@ void TemporaryObjectsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
5555
Options.store(Opts, "Names", utils::options::serializeStringList(Names));
5656
}
5757

58-
} // namespace clang::tidy::zircon
58+
} // namespace clang::tidy::fuchsia

clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.h renamed to clang-tools-extra/clang-tidy/fuchsia/TemporaryObjectsCheck.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ZIRCON_TEMPORARYOBJECTSCHECK_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ZIRCON_TEMPORARYOBJECTSCHECK_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TEMPORARYOBJECTSCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TEMPORARYOBJECTSCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313
#include "../utils/OptionsUtils.h"
1414

15-
namespace clang::tidy::zircon {
15+
namespace clang::tidy::fuchsia {
1616

1717
/// Construction of specific temporary objects in the Zircon kernel is
1818
/// discouraged.
1919
///
2020
/// For the user-facing documentation see:
21-
/// https://clang.llvm.org/extra/clang-tidy/checks/zircon/temporary-objects.html
21+
/// https://clang.llvm.org/extra/clang-tidy/checks/fuchsia/temporary-objects.html
2222
class TemporaryObjectsCheck : public ClangTidyCheck {
2323
public:
2424
TemporaryObjectsCheck(StringRef Name, ClangTidyContext *Context)
@@ -35,6 +35,6 @@ class TemporaryObjectsCheck : public ClangTidyCheck {
3535
std::vector<StringRef> Names;
3636
};
3737

38-
} // namespace clang::tidy::zircon
38+
} // namespace clang::tidy::fuchsia
3939

40-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ZIRCON_TEMPORARYOBJECTSCHECK_H
40+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TEMPORARYOBJECTSCHECK_H

clang-tools-extra/clang-tidy/zircon/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ set(LLVM_LINK_COMPONENTS
44
)
55

66
add_clang_library(clangTidyZirconModule STATIC
7-
TemporaryObjectsCheck.cpp
87
ZirconTidyModule.cpp
98

109
LINK_LIBS
1110
clangTidy
11+
clangTidyFuchsiaModule
1212
clangTidyUtils
1313

1414
DEPENDS

clang-tools-extra/clang-tidy/zircon/ZirconTidyModule.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
#include "../ClangTidy.h"
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
12-
#include "TemporaryObjectsCheck.h"
13-
14-
using namespace clang::ast_matchers;
12+
#include "../fuchsia/TemporaryObjectsCheck.h"
1513

1614
namespace clang::tidy {
1715
namespace zircon {
@@ -20,14 +18,14 @@ namespace zircon {
2018
class ZirconModule : public ClangTidyModule {
2119
public:
2220
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
23-
CheckFactories.registerCheck<TemporaryObjectsCheck>(
21+
CheckFactories.registerCheck<fuchsia::TemporaryObjectsCheck>(
2422
"zircon-temporary-objects");
2523
}
2624
};
2725

2826
// Register the ZirconTidyModule using this statically initialized variable.
2927
static ClangTidyModuleRegistry::Add<ZirconModule>
30-
X("zircon-module", "Adds Zircon kernel checks.");
28+
X("zircon-module", "Adds Zircon kernel checks (deprecated in LLVM 24).");
3129
} // namespace zircon
3230

3331
// This anchor is used to force the linker to link in the generated object file

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Major New Features
4949
Potentially Breaking Changes
5050
----------------------------
5151

52+
- Deprecated the :program:`clang-tidy` ``zircon`` module. All checks have been
53+
moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed
54+
in the 24th release.
55+
5256
- Removed :program:`clang-tidy`'s global options `IgnoreMacros` and
5357
`StrictMode`, which were documented as deprecated since
5458
:program:`clang-tidy-20`. Users should use the check-specific options of the
@@ -163,6 +167,10 @@ Improvements to clang-tidy
163167
scripts by adding the `-hide-progress` option to suppress progress and
164168
informational messages.
165169

170+
- Deprecated the :program:`clang-tidy` ``zircon`` module. All checks have been
171+
moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed
172+
in the 24th release.
173+
166174
New checks
167175
^^^^^^^^^^
168176

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.. title:: clang-tidy - fuchsia-temporary-objects
2+
3+
fuchsia-temporary-objects
4+
=========================
5+
6+
Warns on construction of specific temporary objects in the Zircon kernel.
7+
If the object should be flagged, the fully qualified type name must be
8+
explicitly passed to the check.
9+
10+
For example, given the list of classes "Foo" and "NS::Bar", all of the
11+
following will trigger the warning:
12+
13+
.. code-block:: c++
14+
15+
Foo();
16+
Foo F = Foo();
17+
func(Foo());
18+
19+
namespace NS {
20+
21+
Bar();
22+
23+
}
24+
25+
With the same list, the following will not trigger the warning:
26+
27+
.. code-block:: c++
28+
29+
Foo F; // Non-temporary construction okay
30+
Foo F(param); // Non-temporary construction okay
31+
Foo *F = new Foo(); // New construction okay
32+
33+
Bar(); // Not NS::Bar, so okay
34+
NS::Bar B; // Non-temporary construction okay
35+
36+
Note that objects must be explicitly specified in order to be flagged,
37+
and so objects that inherit a specified object will not be flagged.
38+
39+
This check matches temporary objects without regard for inheritance and so a
40+
prohibited base class type does not similarly prohibit derived class types.
41+
42+
.. code-block:: c++
43+
44+
class Derived : Foo {} // Derived is not explicitly disallowed
45+
Derived(); // and so temporary construction is okay
46+
47+
Options
48+
-------
49+
50+
.. option:: Names
51+
52+
A semi-colon-separated list of fully-qualified names of C++ classes that
53+
should not be constructed as temporaries. Default is empty string.

clang-tools-extra/docs/clang-tidy/checks/list.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Clang-Tidy Checks
222222
:doc:`fuchsia-multiple-inheritance <fuchsia/multiple-inheritance>`,
223223
:doc:`fuchsia-overloaded-operator <fuchsia/overloaded-operator>`,
224224
:doc:`fuchsia-statically-constructed-objects <fuchsia/statically-constructed-objects>`,
225+
:doc:`fuchsia-temporary-objects <fuchsia/temporary-objects>`,
225226
:doc:`fuchsia-trailing-return <fuchsia/trailing-return>`,
226227
:doc:`fuchsia-virtual-inheritance <fuchsia/virtual-inheritance>`,
227228
:doc:`google-build-explicit-make-pair <google/build-explicit-make-pair>`,

clang-tools-extra/docs/clang-tidy/checks/zircon/temporary-objects.rst

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,8 @@
33
zircon-temporary-objects
44
========================
55

6-
Warns on construction of specific temporary objects in the Zircon kernel.
7-
If the object should be flagged, If the object should be flagged, the fully
8-
qualified type name must be explicitly passed to the check.
6+
.. note::
97

10-
For example, given the list of classes "Foo" and "NS::Bar", all of the
11-
following will trigger the warning:
12-
13-
.. code-block:: c++
14-
15-
Foo();
16-
Foo F = Foo();
17-
func(Foo());
18-
19-
namespace NS {
20-
21-
Bar();
22-
23-
}
24-
25-
With the same list, the following will not trigger the warning:
26-
27-
.. code-block:: c++
28-
29-
Foo F; // Non-temporary construction okay
30-
Foo F(param); // Non-temporary construction okay
31-
Foo *F = new Foo(); // New construction okay
32-
33-
Bar(); // Not NS::Bar, so okay
34-
NS::Bar B; // Non-temporary construction okay
35-
36-
Note that objects must be explicitly specified in order to be flagged,
37-
and so objects that inherit a specified object will not be flagged.
38-
39-
This check matches temporary objects without regard for inheritance and so a
40-
prohibited base class type does not similarly prohibit derived class types.
41-
42-
.. code-block:: c++
43-
44-
class Derived : Foo {} // Derived is not explicitly disallowed
45-
Derived(); // and so temporary construction is okay
46-
47-
Options
48-
-------
49-
50-
.. option:: Names
51-
52-
A semi-colon-separated list of fully-qualified names of C++ classes that
53-
should not be constructed as temporaries. Default is empty.
8+
The `zircon-temporary-objects` check has been deprecated and will be removed
9+
in 24th release of LLVM. Please use
10+
:doc:`fuchsia-temporary-objects <../fuchsia/temporary-objects>` instead.

0 commit comments

Comments
 (0)