clang-tools  4.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"
20 #include "FloatLoopCounter.h"
21 #include "LimitedRandomnessCheck.h"
22 #include "SetLongJmpCheck.h"
24 #include "StrToNumCheck.h"
27 
28 namespace clang {
29 namespace tidy {
30 namespace cert {
31 
32 class CERTModule : public ClangTidyModule {
33 public:
34  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
35  // C++ checkers
36  // DCL
37  CheckFactories.registerCheck<VariadicFunctionDefCheck>("cert-dcl50-cpp");
39  "cert-dcl54-cpp");
41  "cert-dcl59-cpp");
42  // OOP
44  "cert-oop11-cpp");
45  // ERR
47  "cert-err09-cpp");
48  CheckFactories.registerCheck<SetLongJmpCheck>("cert-err52-cpp");
49  CheckFactories.registerCheck<StaticObjectExceptionCheck>("cert-err58-cpp");
50  CheckFactories.registerCheck<ThrownExceptionTypeCheck>("cert-err60-cpp");
52  "cert-err61-cpp");
53  // MSC
54  CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc50-cpp");
55 
56  // C checkers
57  // DCL
58  CheckFactories.registerCheck<misc::StaticAssertCheck>("cert-dcl03-c");
59  // ENV
60  CheckFactories.registerCheck<CommandProcessorCheck>("cert-env33-c");
61  // FLP
62  CheckFactories.registerCheck<FloatLoopCounter>("cert-flp30-c");
63  // FIO
64  CheckFactories.registerCheck<misc::NonCopyableObjectsCheck>("cert-fio38-c");
65  // ERR
66  CheckFactories.registerCheck<StrToNumCheck>("cert-err34-c");
67  // MSC
68  CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc30-c");
69  }
70 };
71 
72 } // namespace cert
73 
74 // Register the MiscTidyModule using this statically initialized variable.
75 static ClangTidyModuleRegistry::Add<cert::CERTModule>
76  X("cert-module",
77  "Adds lint checks corresponding to CERT secure coding guidelines.");
78 
79 // This anchor is used to force the linker to link in the generated object file
80 // and thus register the CERTModule.
81 volatile int CERTModuleAnchorSource = 0;
82 
83 } // namespace tidy
84 } // namespace clang
Pseudorandom number generators are not genuinely random.
static ClangTidyModuleRegistry::Add< cert::CERTModule > X("cert-module","Adds lint checks corresponding to CERT secure coding guidelines.")
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...
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).