Skip to content

Commit ac312ee

Browse files
committed
Fix some grammar details and the documentation.
Close: #157296
1 parent fd994fd commit ac312ee

File tree

11 files changed

+42
-31
lines changed

11 files changed

+42
-31
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#include "ParentVirtualCallCheck.h"
6565
#include "PointerArithmeticOnPolymorphicObjectCheck.h"
6666
#include "PosixReturnCheck.h"
67-
#include "ProperlySeededRandomGeneratorCheck.h"
67+
#include "RandomGeneratorSeedCheck.h"
6868
#include "RawMemoryCallOnNonTrivialTypeCheck.h"
6969
#include "RedundantBranchConditionCheck.h"
7070
#include "ReservedIdentifierCheck.h"
@@ -228,7 +228,7 @@ class BugproneModule : public ClangTidyModule {
228228
CheckFactories.registerCheck<ParentVirtualCallCheck>(
229229
"bugprone-parent-virtual-call");
230230
CheckFactories.registerCheck<PosixReturnCheck>("bugprone-posix-return");
231-
CheckFactories.registerCheck<ProperlySeededRandomGeneratorCheck>(
231+
CheckFactories.registerCheck<RandomGeneratorSeedCheck>(
232232
"bugprone-random-generator-seed");
233233
CheckFactories.registerCheck<RawMemoryCallOnNonTrivialTypeCheck>(
234234
"bugprone-raw-memory-call-on-non-trivial-type");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ add_clang_library(clangTidyBugproneModule STATIC
6565
ParentVirtualCallCheck.cpp
6666
PointerArithmeticOnPolymorphicObjectCheck.cpp
6767
PosixReturnCheck.cpp
68-
ProperlySeededRandomGeneratorCheck.cpp
68+
RandomGeneratorSeedCheck.cpp
6969
RawMemoryCallOnNonTrivialTypeCheck.cpp
7070
RedundantBranchConditionCheck.cpp
7171
ReservedIdentifierCheck.cpp

clang-tools-extra/clang-tidy/bugprone/ProperlySeededRandomGeneratorCheck.cpp renamed to clang-tools-extra/clang-tidy/bugprone/RandomGeneratorSeedCheck.cpp

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

9-
#include "ProperlySeededRandomGeneratorCheck.h"
9+
#include "RandomGeneratorSeedCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
1212
#include "llvm/ADT/STLExtras.h"
1313

1414
using namespace clang::ast_matchers;
1515

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

18-
ProperlySeededRandomGeneratorCheck::ProperlySeededRandomGeneratorCheck(
18+
RandomGeneratorSeedCheck::RandomGeneratorSeedCheck(
1919
StringRef Name, ClangTidyContext *Context)
2020
: ClangTidyCheck(Name, Context),
2121
RawDisallowedSeedTypes(
2222
Options.get("DisallowedSeedTypes", "time_t,std::time_t")) {
2323
RawDisallowedSeedTypes.split(DisallowedSeedTypes, ',');
2424
}
2525

26-
void ProperlySeededRandomGeneratorCheck::storeOptions(
26+
void RandomGeneratorSeedCheck::storeOptions(
2727
ClangTidyOptions::OptionMap &Opts) {
2828
Options.store(Opts, "DisallowedSeedTypes", RawDisallowedSeedTypes);
2929
}
3030

31-
void ProperlySeededRandomGeneratorCheck::registerMatchers(MatchFinder *Finder) {
31+
void RandomGeneratorSeedCheck::registerMatchers(MatchFinder *Finder) {
3232
auto RandomGeneratorEngineDecl = cxxRecordDecl(hasAnyName(
3333
"::std::linear_congruential_engine", "::std::mersenne_twister_engine",
3434
"::std::subtract_with_carry_engine", "::std::discard_block_engine",
@@ -75,7 +75,7 @@ void ProperlySeededRandomGeneratorCheck::registerMatchers(MatchFinder *Finder) {
7575
this);
7676
}
7777

78-
void ProperlySeededRandomGeneratorCheck::check(
78+
void RandomGeneratorSeedCheck::check(
7979
const MatchFinder::MatchResult &Result) {
8080
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructExpr>("ctor");
8181
if (Ctor)
@@ -91,7 +91,7 @@ void ProperlySeededRandomGeneratorCheck::check(
9191
}
9292

9393
template <class T>
94-
void ProperlySeededRandomGeneratorCheck::checkSeed(
94+
void RandomGeneratorSeedCheck::checkSeed(
9595
const MatchFinder::MatchResult &Result, const T *Func) {
9696
if (Func->getNumArgs() == 0 || Func->getArg(0)->isDefaultArgument()) {
9797
diag(Func->getExprLoc(),
@@ -118,4 +118,4 @@ void ProperlySeededRandomGeneratorCheck::checkSeed(
118118
}
119119
}
120120

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

clang-tools-extra/clang-tidy/bugprone/ProperlySeededRandomGeneratorCheck.h renamed to clang-tools-extra/clang-tidy/bugprone/RandomGeneratorSeedCheck.h

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

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PROPERLY_SEEDED_RANDOM_GENERATOR_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PROPERLY_SEEDED_RANDOM_GENERATOR_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RANDOMGENERATORSEEDCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RANDOMGENERATORSEEDCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313
#include <string>
@@ -21,9 +21,9 @@ namespace clang::tidy::bugprone {
2121
///
2222
/// For the user-facing documentation see:
2323
/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/random-generator-seed.html
24-
class ProperlySeededRandomGeneratorCheck : public ClangTidyCheck {
24+
class RandomGeneratorSeedCheck : public ClangTidyCheck {
2525
public:
26-
ProperlySeededRandomGeneratorCheck(StringRef Name, ClangTidyContext *Context);
26+
RandomGeneratorSeedCheck(StringRef Name, ClangTidyContext *Context);
2727
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2828
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2929
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
@@ -39,4 +39,4 @@ class ProperlySeededRandomGeneratorCheck : public ClangTidyCheck {
3939

4040
} // namespace clang::tidy::bugprone
4141

42-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PROPERLY_SEEDED_RANDOM_GENERATOR_H
42+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RANDOMGENERATORSEEDCHECK_H

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "../bugprone/DefaultOperatorNewOnOveralignedTypeCheck.h"
1616
#include "../bugprone/FloatLoopCounterCheck.h"
1717
#include "../bugprone/PointerArithmeticOnPolymorphicObjectCheck.h"
18-
#include "../bugprone/ProperlySeededRandomGeneratorCheck.h"
18+
#include "../bugprone/RandomGeneratorSeedCheck.h"
1919
#include "../bugprone/RawMemoryCallOnNonTrivialTypeCheck.h"
2020
#include "../bugprone/ReservedIdentifierCheck.h"
2121
#include "../bugprone/SignalHandlerCheck.h"
@@ -41,8 +41,6 @@
4141
#include "../readability/EnumInitialValueCheck.h"
4242
#include "../readability/UppercaseLiteralSuffixCheck.h"
4343
#include "LimitedRandomnessCheck.h"
44-
#include "ProperlySeededRandomGeneratorCheck.h"
45-
#include "MutatingCopyCheck.h"
4644
#include "ThrownExceptionTypeCheck.h"
4745

4846
namespace {
@@ -273,7 +271,7 @@ class CERTModule : public ClangTidyModule {
273271
"cert-mem57-cpp");
274272
// MSC
275273
CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc50-cpp");
276-
CheckFactories.registerCheck<bugprone::ProperlySeededRandomGeneratorCheck>(
274+
CheckFactories.registerCheck<bugprone::RandomGeneratorSeedCheck>(
277275
"cert-msc51-cpp");
278276
CheckFactories.registerCheck<bugprone::SignalHandlerCheck>(
279277
"cert-msc54-cpp");
@@ -326,7 +324,7 @@ class CERTModule : public ClangTidyModule {
326324
CheckFactories.registerCheck<bugprone::UnsafeFunctionsCheck>(
327325
"cert-msc24-c");
328326
CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc30-c");
329-
CheckFactories.registerCheck<bugprone::ProperlySeededRandomGeneratorCheck>(
327+
CheckFactories.registerCheck<bugprone::RandomGeneratorSeedCheck>(
330328
"cert-msc32-c");
331329
CheckFactories.registerCheck<bugprone::UnsafeFunctionsCheck>(
332330
"cert-msc33-c");

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ set(LLVM_LINK_COMPONENTS
66
add_clang_library(clangTidyCERTModule STATIC
77
CERTTidyModule.cpp
88
LimitedRandomnessCheck.cpp
9-
ProperlySeededRandomGeneratorCheck.cpp
10-
MutatingCopyCheck.cpp
119
ThrownExceptionTypeCheck.cpp
1210

1311
LINK_LIBS

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ New check aliases
279279
<clang-tidy/checks/bugprone/default-operator-new-on-overaligned-type>`
280280
keeping initial check as an alias to the new one.
281281

282+
- Renamed :doc:`cert-msc32-c <clang-tidy/checks/cert/msc32-c>` to
283+
:doc:`bugprone-random-generator-seed
284+
<clang-tidy/checks/bugprone/random-generator-seed>`
285+
keeping initial check as an alias to the new one.
286+
287+
- Renamed :doc:`cert-msc51-cpp <clang-tidy/checks/cert/msc51-cpp>` to
288+
:doc:`bugprone-random-generator-seed
289+
<clang-tidy/checks/bugprone/random-generator-seed>`
290+
keeping initial check as an alias to the new one.
291+
282292
- Renamed :doc:`cert-oop57-cpp <clang-tidy/checks/cert/oop57-cpp>` to
283293
:doc:`bugprone-raw-memory-call-on-non-trivial-type
284294
<clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type>`

clang-tools-extra/docs/clang-tidy/checks/bugprone/random-generator-seed.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
bugprone-random-generator-seed
44
==============================
55

6-
This check flags all pseudo-random number engines, engine adaptor
6+
Flags all pseudo-random number engines, engine adaptor
77
instantiations and ``srand()`` when initialized or seeded with default argument,
88
constant expression or any user-configurable type. Pseudo-random number
99
engines seeded with a predictable value may cause vulnerabilities e.g. in
1010
security protocols.
11-
This is a CERT security rule, see
12-
`MSC51-CPP. Ensure your random number generator is properly seeded
13-
<https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC51-CPP.+Ensure+your+random+number+generator+is+properly+seeded>`_ and
14-
`MSC32-C. Properly seed pseudorandom number generators
15-
<https://wiki.sei.cmu.edu/confluence/display/c/MSC32-C.+Properly+seed+pseudorandom+number+generators>`_.
1611

1712
Examples:
1813

@@ -38,3 +33,12 @@ Options
3833

3934
A comma-separated list of the type names which are disallowed.
4035
Default value is `time_t,std::time_t`.
36+
37+
References
38+
----------
39+
40+
This is a CERT security rule, see
41+
`MSC51-CPP. Ensure your random number generator is properly seeded
42+
<https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC51-CPP.+Ensure+your+random+number+generator+is+properly+seeded>`_ and
43+
`MSC32-C. Properly seed pseudorandom number generators
44+
<https://wiki.sei.cmu.edu/confluence/display/c/MSC32-C.+Properly+seed+pseudorandom+number+generators>`_.

clang-tools-extra/docs/clang-tidy/checks/cert/msc32-c.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ cert-msc32-c
66
============
77

88
The `cert-msc32-c` check is an alias, please see
9-
:doc:`bugprone-random-generator-seed <../bugprone/random-generator-seed>` for more information.
9+
:doc:`bugprone-random-generator-seed <../bugprone/random-generator-seed.html>` for more information.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ cert-msc51-cpp
44
==============
55

66
The `cert-msc51-cpp` check is an alias, please see
7-
:doc:`bugprone-random-generator-seed <../bugprone/random-generator-seed>` for more information.
7+
:doc:`bugprone-random-generator-seed <../bugprone/random-generator-seed.html>` for more information.

0 commit comments

Comments
 (0)