Skip to content

Commit 106c7ed

Browse files
committed
Rename cert-mem57-cpp to bugprone-default-operator-new-alignment
1 parent 0926265 commit 106c7ed

File tree

13 files changed

+59
-35
lines changed

13 files changed

+59
-35
lines changed

clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "CopyConstructorInitCheck.h"
2525
#include "CrtpConstructorAccessibilityCheck.h"
2626
#include "DanglingHandleCheck.h"
27+
#include "DefaultOperatorNewAlignmentCheck.h"
2728
#include "DerivedMethodShadowingBaseMethodCheck.h"
2829
#include "DynamicStaticInitializersCheck.h"
2930
#include "EasilySwappableParametersCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
139140
"bugprone-copy-constructor-init");
140141
CheckFactories.registerCheck<DanglingHandleCheck>(
141142
"bugprone-dangling-handle");
143+
CheckFactories.registerCheck<DefaultOperatorNewAlignmentCheck>(
144+
"bugprone-default-operator-new-alignment");
142145
CheckFactories.registerCheck<DerivedMethodShadowingBaseMethodCheck>(
143146
"bugprone-derived-method-shadowing-base-method");
144147
CheckFactories.registerCheck<DynamicStaticInitializersCheck>(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ add_clang_library(clangTidyBugproneModule STATIC
2020
CopyConstructorInitCheck.cpp
2121
CrtpConstructorAccessibilityCheck.cpp
2222
DanglingHandleCheck.cpp
23+
DefaultOperatorNewAlignmentCheck.cpp
2324
DerivedMethodShadowingBaseMethodCheck.cpp
2425
DynamicStaticInitializersCheck.cpp
2526
EasilySwappableParametersCheck.cpp

clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp renamed to clang-tools-extra/clang-tidy/bugprone/DefaultOperatorNewAlignmentCheck.cpp

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

1414
using namespace clang::ast_matchers;
1515

16-
namespace clang::tidy::cert {
16+
namespace clang::tidy::bugprone {
1717

1818
void DefaultOperatorNewAlignmentCheck::registerMatchers(MatchFinder *Finder) {
1919
Finder->addMatcher(
@@ -61,4 +61,4 @@ void DefaultOperatorNewAlignmentCheck::check(
6161
<< (SpecifiedAlignment / CharWidth);
6262
}
6363

64-
} // namespace clang::tidy::cert
64+
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.h renamed to clang-tools-extra/clang-tidy/bugprone/DefaultOperatorNewAlignmentCheck.h

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

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DEFAULTOPERATORNEWALIGNMENTCHECK_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DEFAULTOPERATORNEWALIGNMENTCHECK_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DEFAULTOPERATORNEWALIGNMENTCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DEFAULTOPERATORNEWALIGNMENTCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

14-
namespace clang::tidy::cert {
14+
namespace clang::tidy::bugprone {
1515

1616
/// Checks if an object of type with extended alignment is allocated by using
1717
/// the default operator new.
1818
///
1919
/// For the user-facing documentation see:
20-
/// https://clang.llvm.org/extra/clang-tidy/checks/cert/mem57-cpp.html
20+
/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/default-operator-new-alignment.html
2121
class DefaultOperatorNewAlignmentCheck : public ClangTidyCheck {
2222
public:
2323
DefaultOperatorNewAlignmentCheck(StringRef Name, ClangTidyContext *Context)
@@ -29,6 +29,6 @@ class DefaultOperatorNewAlignmentCheck : public ClangTidyCheck {
2929
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3030
};
3131

32-
} // namespace clang::tidy::cert
32+
} // namespace clang::tidy::bugprone
3333

34-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DEFAULTOPERATORNEWALIGNMENTCHECK_H
34+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DEFAULTOPERATORNEWALIGNMENTCHECK_H

clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../ClangTidyModuleRegistry.h"
1212
#include "../bugprone/BadSignalToKillThreadCheck.h"
1313
#include "../bugprone/CommandProcessorCheck.h"
14+
#include "../bugprone/DefaultOperatorNewAlignmentCheck.h"
1415
#include "../bugprone/PointerArithmeticOnPolymorphicObjectCheck.h"
1516
#include "../bugprone/ReservedIdentifierCheck.h"
1617
#include "../bugprone/SignalHandlerCheck.h"
@@ -34,7 +35,6 @@
3435
#include "../performance/MoveConstructorInitCheck.h"
3536
#include "../readability/EnumInitialValueCheck.h"
3637
#include "../readability/UppercaseLiteralSuffixCheck.h"
37-
#include "DefaultOperatorNewAlignmentCheck.h"
3838
#include "DontModifyStdNamespaceCheck.h"
3939
#include "FloatLoopCounter.h"
4040
#include "LimitedRandomnessCheck.h"
@@ -265,7 +265,7 @@ class CERTModule : public ClangTidyModule {
265265
CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
266266
"cert-err61-cpp");
267267
// MEM
268-
CheckFactories.registerCheck<DefaultOperatorNewAlignmentCheck>(
268+
CheckFactories.registerCheck<bugprone::DefaultOperatorNewAlignmentCheck>(
269269
"cert-mem57-cpp");
270270
// MSC
271271
CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc50-cpp");

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set(LLVM_LINK_COMPONENTS
55

66
add_clang_library(clangTidyCERTModule STATIC
77
CERTTidyModule.cpp
8-
DefaultOperatorNewAlignmentCheck.cpp
98
DontModifyStdNamespaceCheck.cpp
109
FloatLoopCounter.cpp
1110
LimitedRandomnessCheck.cpp

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ New check aliases
254254
<clang-tidy/checks/bugprone/throwing-static-initialization>`
255255
keeping initial check as an alias to the new one.
256256

257+
- Renamed :doc:`cert-mem57-cpp <clang-tidy/checks/cert/mem57-cpp>` to
258+
:doc:`bugprone-default-operator-new-alignment
259+
<clang-tidy/checks/bugprone/default-operator-new-alignment>`
260+
keeping initial check as an alias to the new one.
261+
257262
Changes in existing checks
258263
^^^^^^^^^^^^^^^^^^^^^^^^^^
259264

@@ -352,7 +357,7 @@ Changes in existing checks
352357

353358
- Improved :doc:`misc-const-correctness
354359
<clang-tidy/checks/misc/const-correctness>` check to avoid false
355-
positives when pointers is transferred to non-const references
360+
positives when pointers is transferred to non-const references
356361
and avoid false positives of function pointer and fix false
357362
positives on return of non-const pointer.
358363

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. title:: clang-tidy - bugprone-default-operator-new-alignment
2+
3+
bugprone-default-operator-new-alignment
4+
=======================================
5+
6+
This check flags uses of default ``operator new`` where the type has extended
7+
alignment (an alignment greater than the fundamental alignment). (The default
8+
``operator new`` is guaranteed to provide the correct alignment if the
9+
requested alignment is less or equal to the fundamental alignment).
10+
Only cases are detected (by design) where the ``operator new`` is not
11+
user-defined and is not a placement new (the reason is that in these cases we
12+
assume that the user provided the correct memory allocation).
13+
14+
References
15+
----------
16+
17+
This check corresponds to the CERT C++ Coding Standard rule
18+
`MEM57-CPP. Avoid using default operator new for over-aligned types
19+
<https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM57-CPP.+Avoid+using+default+operator+new+for+over-aligned+types>`_.

clang-tools-extra/docs/clang-tidy/checks/cert/mem57-cpp.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
cert-mem57-cpp
44
==============
55

6-
This check flags uses of default ``operator new`` where the type has extended
7-
alignment (an alignment greater than the fundamental alignment). (The default
8-
``operator new`` is guaranteed to provide the correct alignment if the
9-
requested alignment is less or equal to the fundamental alignment).
10-
Only cases are detected (by design) where the ``operator new`` is not
11-
user-defined and is not a placement new (the reason is that in these cases we
12-
assume that the user provided the correct memory allocation).
6+
The `cert-mem57-cpp` is an aliaes, please see
7+
`bugprone-default-operator-new-alignment <../bugprone/default-operator-new-alignment>`_
8+
for more information.
139

1410
This check corresponds to the CERT C++ Coding Standard rule
1511
`MEM57-CPP. Avoid using default operator new for over-aligned types

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Clang-Tidy Checks
9393
:doc:`bugprone-crtp-constructor-accessibility <bugprone/crtp-constructor-accessibility>`, "Yes"
9494
:doc:`bugprone-dangling-handle <bugprone/dangling-handle>`,
9595
:doc:`bugprone-derived-method-shadowing-base-method <bugprone/derived-method-shadowing-base-method>`,
96+
:doc:`bugprone-default-operator-new-alignment <bugprone/default-operator-new-alignment>`,
9697
:doc:`bugprone-dynamic-static-initializers <bugprone/dynamic-static-initializers>`,
9798
:doc:`bugprone-easily-swappable-parameters <bugprone/easily-swappable-parameters>`,
9899
:doc:`bugprone-empty-catch <bugprone/empty-catch>`,
@@ -177,7 +178,6 @@ Clang-Tidy Checks
177178
:doc:`cert-err33-c <cert/err33-c>`,
178179
:doc:`cert-err60-cpp <cert/err60-cpp>`,
179180
:doc:`cert-flp30-c <cert/flp30-c>`,
180-
:doc:`cert-mem57-cpp <cert/mem57-cpp>`,
181181
:doc:`cert-msc50-cpp <cert/msc50-cpp>`,
182182
:doc:`cert-msc51-cpp <cert/msc51-cpp>`,
183183
:doc:`cert-oop57-cpp <cert/oop57-cpp>`,
@@ -452,6 +452,7 @@ Check aliases
452452
:doc:`cert-fio38-c <cert/fio38-c>`, :doc:`misc-non-copyable-objects <misc/non-copyable-objects>`,
453453
:doc:`cert-flp37-c <cert/flp37-c>`, :doc:`bugprone-suspicious-memory-comparison <bugprone/suspicious-memory-comparison>`,
454454
:doc:`cert-int09-c <cert/int09-c>`, :doc:`readability-enum-initial-value <readability/enum-initial-value>`, "Yes"
455+
:doc:`cert-mem57-cpp <cert/mem57-cpp>`, :doc:`bugprone-default-operator-new-alignment <bugprone/default-operator-new-alignment>`,
455456
:doc:`cert-msc24-c <cert/msc24-c>`, :doc:`bugprone-unsafe-functions <bugprone/unsafe-functions>`,
456457
:doc:`cert-msc30-c <cert/msc30-c>`, :doc:`cert-msc50-cpp <cert/msc50-cpp>`,
457458
:doc:`cert-msc32-c <cert/msc32-c>`, :doc:`cert-msc51-cpp <cert/msc51-cpp>`,

0 commit comments

Comments
 (0)