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
91