clang-tools 6.0.0

CERTTidyModule.cpp
Go to the documentation of this file.
1 //===--- CERTTidyModule.cpp - clang-tidy ----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "../ClangTidy.h"
11 #include "../ClangTidyModule.h"
12 #include "../ClangTidyModuleRegistry.h"
13 #include "../google/UnnamedNamespaceInHeaderCheck.h"
14 #include "../misc/NewDeleteOverloadsCheck.h"
15 #include "../misc/NonCopyableObjects.h"
16 #include "../misc/StaticAssertCheck.h"
17 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
18 #include "../performance/MoveConstructorInitCheck.h"
19 #include "CommandProcessorCheck.h"
20 #include "DontModifyStdNamespaceCheck.h"
21 #include "FloatLoopCounter.h"
22 #include "LimitedRandomnessCheck.h"
23 #include "PostfixOperatorCheck.h"
24 #include "SetLongJmpCheck.h"
25 #include "StaticObjectExceptionCheck.h"
26 #include "StrToNumCheck.h"
27 #include "ThrownExceptionTypeCheck.h"
28 #include "VariadicFunctionDefCheck.h"
29
30 namespace clang {
31 namespace tidy {
32 namespace cert {
33
34 class CERTModule : public ClangTidyModule {
35 public:
36 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
37 // C++ checkers
38 // DCL
39 CheckFactories.registerCheck<PostfixOperatorCheck>(
40 "cert-dcl21-cpp");
41 CheckFactories.registerCheck<VariadicFunctionDefCheck>("cert-dcl50-cpp");
42 CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
43 "cert-dcl54-cpp");
44 CheckFactories.registerCheck<DontModifyStdNamespaceCheck>(
45 "cert-dcl58-cpp");
46 CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
47 "cert-dcl59-cpp");
48 // OOP
49 CheckFactories.registerCheck<performance::MoveConstructorInitCheck>(
50 "cert-oop11-cpp");
51 // ERR
52 CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
53 "cert-err09-cpp");
54 CheckFactories.registerCheck<SetLongJmpCheck>("cert-err52-cpp");
55 CheckFactories.registerCheck<StaticObjectExceptionCheck>("cert-err58-cpp");
56 CheckFactories.registerCheck<ThrownExceptionTypeCheck>("cert-err60-cpp");
57 CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
58 "cert-err61-cpp");
59 // MSC
60 CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc50-cpp");
61
62 // C checkers
63 // DCL
64 CheckFactories.registerCheck<misc::StaticAssertCheck>("cert-dcl03-c");
65 // ENV
66 CheckFactories.registerCheck<CommandProcessorCheck>("cert-env33-c");
67 // FLP
68 CheckFactories.registerCheck<FloatLoopCounter>("cert-flp30-c");
69 // FIO
70 CheckFactories.registerCheck<misc::NonCopyableObjectsCheck>("cert-fio38-c");
71 // ERR
72 CheckFactories.registerCheck<StrToNumCheck>("cert-err34-c");
73 // MSC
74 CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc30-c");
75 }
76 };
77
78 } // namespace cert
79
80 // Register the MiscTidyModule using this statically initialized variable.
81 static ClangTidyModuleRegistry::Add<cert::CERTModule>
82 X("cert-module",
83 "Adds lint checks corresponding to CERT secure coding guidelines.");
84
85 // This anchor is used to force the linker to link in the generated object file
86 // and thus register the CERTModule.
87 volatile int CERTModuleAnchorSource = 0;
88
89 } // namespace tidy
90 } // namespace clang
clang::tidy::cert::PostfixOperatorCheck
Checks if the overloaded postfix ++ and – operator return a constant object.
Definition: PostfixOperatorCheck.h:24
PostfixOperatorCheck.h
clang::tidy::cert::LimitedRandomnessCheck
Pseudorandom number generators are not genuinely random.
Definition: LimitedRandomnessCheck.h:26
clang::tidy::misc::ThrowByValueCatchByReferenceCheck
checks for locations that do not throw by value
Definition: ThrowByValueCatchByReferenceCheck.h:30
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::misc::StaticAssertCheck
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Definition: StaticAssertCheck.h:26
SetLongJmpCheck.h
clang::tidy::cert::CommandProcessorCheck
Execution of a command processor can lead to security vulnerabilities, and is generally not required...
Definition: CommandProcessorCheck.h:26
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::cert::CERTModule
Definition: CERTTidyModule.cpp:34
ThrownExceptionTypeCheck.h
clang::tidy::cert::StrToNumCheck
Guards against use of string conversion functions that do not have reasonable error handling for conv...
Definition: StrToNumCheck.h:24
StaticObjectExceptionCheck.h
clang::tidy::cert::StaticObjectExceptionCheck
Checks whether the constructor for a static or thread_local object will throw.
Definition: StaticObjectExceptionCheck.h:24
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
LimitedRandomnessCheck.h
clang::tidy::misc::NewDeleteOverloadsCheck
Definition: NewDeleteOverloadsCheck.h:21
clang::tidy::misc::NonCopyableObjectsCheck
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
Definition: NonCopyableObjects.h:21
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck
Finds anonymous namespaces in headers.
Definition: UnnamedNamespaceInHeaderCheck.h:33
VariadicFunctionDefCheck.h
clang::tidy::performance::MoveConstructorInitCheck
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Definition: MoveConstructorInitCheck.h:27
clang::tidy::cert::ThrownExceptionTypeCheck
Checks whether a thrown object is nothrow copy constructible.
Definition: ThrownExceptionTypeCheck.h:23
clang::tidy::cert::SetLongJmpCheck
Guards against use of setjmp/longjmp in C++ code.
Definition: SetLongJmpCheck.h:23
clang::tidy::CERTModuleAnchorSource
volatile int CERTModuleAnchorSource
Definition: CERTTidyModule.cpp:87
clang::tidy::X
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
CommandProcessorCheck.h
clang::tidy::cert::FloatLoopCounter
This check diagnoses when the loop induction expression of a for loop has floating-point type...
Definition: FloatLoopCounter.h:25
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::cert::DontModifyStdNamespaceCheck
Modification of the std or posix namespace can result in undefined behavior.
Definition: DontModifyStdNamespaceCheck.h:24
clang::tidy::cert::CERTModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: CERTTidyModule.cpp:36
StrToNumCheck.h
FloatLoopCounter.h
clang::tidy::cert::VariadicFunctionDefCheck
Guards against any C-style variadic function definitions (not declarations).
Definition: VariadicFunctionDefCheck.h:23
DontModifyStdNamespaceCheck.h