clang-tools  8.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 "../readability/UppercaseLiteralSuffixCheck.h"
20 #include "CommandProcessorCheck.h"
22 #include "FloatLoopCounter.h"
23 #include "LimitedRandomnessCheck.h"
24 #include "PostfixOperatorCheck.h"
26 #include "SetLongJmpCheck.h"
28 #include "StrToNumCheck.h"
31 
32 namespace clang {
33 namespace tidy {
34 namespace cert {
35 
36 class CERTModule : public ClangTidyModule {
37 public:
38  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
39  // C++ checkers
40  // DCL
41  CheckFactories.registerCheck<PostfixOperatorCheck>(
42  "cert-dcl21-cpp");
43  CheckFactories.registerCheck<VariadicFunctionDefCheck>("cert-dcl50-cpp");
45  "cert-dcl54-cpp");
47  "cert-dcl58-cpp");
49  "cert-dcl59-cpp");
50  // OOP
52  "cert-oop11-cpp");
53  // ERR
55  "cert-err09-cpp");
56  CheckFactories.registerCheck<SetLongJmpCheck>("cert-err52-cpp");
57  CheckFactories.registerCheck<StaticObjectExceptionCheck>("cert-err58-cpp");
58  CheckFactories.registerCheck<ThrownExceptionTypeCheck>("cert-err60-cpp");
60  "cert-err61-cpp");
61  // MSC
62  CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc50-cpp");
64  "cert-msc51-cpp");
65 
66  // C checkers
67  // DCL
68  CheckFactories.registerCheck<misc::StaticAssertCheck>("cert-dcl03-c");
70  "cert-dcl16-c");
71  // ENV
72  CheckFactories.registerCheck<CommandProcessorCheck>("cert-env33-c");
73  // FLP
74  CheckFactories.registerCheck<FloatLoopCounter>("cert-flp30-c");
75  // FIO
76  CheckFactories.registerCheck<misc::NonCopyableObjectsCheck>("cert-fio38-c");
77  // ERR
78  CheckFactories.registerCheck<StrToNumCheck>("cert-err34-c");
79  // MSC
80  CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc30-c");
82  "cert-msc32-c");
83  }
84 
86  ClangTidyOptions Options;
88  Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
89  return Options;
90  }
91 };
92 
93 } // namespace cert
94 
95 // Register the MiscTidyModule using this statically initialized variable.
96 static ClangTidyModuleRegistry::Add<cert::CERTModule>
97  X("cert-module",
98  "Adds lint checks corresponding to CERT secure coding guidelines.");
99 
100 // This anchor is used to force the linker to link in the generated object file
101 // and thus register the CERTModule.
102 volatile int CERTModuleAnchorSource = 0;
103 
104 } // namespace tidy
105 } // namespace clang
Checks if the overloaded postfix ++ and – operator return a constant object.
Pseudorandom number generators are not genuinely random.
Detects when the integral literal or floating point literal has non-uppercase suffix, and suggests to make the suffix uppercase.
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...
Contains options for clang-tidy.
Execution of a command processor can lead to security vulnerabilities, and is generally not required...
A collection of ClangTidyCheckFactory instances.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
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 ...
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Checks whether a thrown object is nothrow copy constructible.
Guards against use of setjmp/longjmp in C++ code.
volatile int CERTModuleAnchorSource
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
std::map< std::string, std::string > OptionMap
This check diagnoses when the loop induction expression of a for loop has floating-point type...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
ClangTidyOptions getModuleOptions() override
Gets default options for checks defined in this module.
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).