clang-tools  5.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/MoveConstructorInitCheck.h"
15 #include "../misc/NewDeleteOverloadsCheck.h"
16 #include "../misc/NonCopyableObjects.h"
17 #include "../misc/StaticAssertCheck.h"
18 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
19 #include "CommandProcessorCheck.h"
21 #include "FloatLoopCounter.h"
22 #include "LimitedRandomnessCheck.h"
23 #include "PostfixOperatorCheck.h"
24 #include "SetLongJmpCheck.h"
26 #include "StrToNumCheck.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");
43  "cert-dcl54-cpp");
45  "cert-dcl58-cpp");
47  "cert-dcl59-cpp");
48  // OOP
50  "cert-oop11-cpp");
51  // ERR
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");
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
Checks if the overloaded postfix ++ and – operator return a constant object.
Pseudorandom number generators are not genuinely random.
checks for locations that do not throw by value
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Execution of a command processor can lead to security vulnerabilities, and is generally not required...
A collection of ClangTidyCheckFactory instances.
Guards against use of string conversion functions that do not have reasonable error handling for conv...
Definition: StrToNumCheck.h:24
Checks whether the constructor for a static or thread_local object will throw.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
Checks whether a thrown object is nothrow copy constructible.
Guards against use of setjmp/longjmp in C++ code.
volatile int CERTModuleAnchorSource
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
This check diagnoses when the loop induction expression of a for loop has floating-point type...
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module","Adds checks for bugprone code constructs.")
Modification of the std or posix namespace can result in undefined behavior.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Guards against any C-style variadic function definitions (not declarations).