blob: 4fbcc198956caa1bc84e5b378114a7aa9df0ebbb [file] [log] [blame]
Aaron Ballmanea2f90c2015-10-02 13:27:19 +00001//===--- 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"
Aaron Ballmana742b842015-10-13 20:42:41 +000018#include "../misc/ThrowByValueCatchByReferenceCheck.h"
Aaron Ballman527a4202016-02-22 16:01:06 +000019#include "CommandProcessorCheck.h"
Aaron Ballman611d2e42016-02-19 14:03:20 +000020#include "FloatLoopCounter.h"
Aaron Ballmane4b17652015-10-08 19:54:43 +000021#include "SetLongJmpCheck.h"
Aaron Ballman43aef4c2015-12-01 14:05:39 +000022#include "StaticObjectExceptionCheck.h"
Aaron Ballman5a786dd2015-11-16 19:17:43 +000023#include "ThrownExceptionTypeCheck.h"
Aaron Ballman46bc3042015-10-05 20:08:59 +000024#include "VariadicFunctionDefCheck.h"
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000025
26namespace clang {
27namespace tidy {
Aaron Ballman1284f042016-01-04 14:31:14 +000028namespace cert {
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000029
30class CERTModule : public ClangTidyModule {
31public:
32 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
33 // C++ checkers
34 // DCL
Aaron Ballman46bc3042015-10-05 20:08:59 +000035 CheckFactories.registerCheck<VariadicFunctionDefCheck>(
36 "cert-dcl50-cpp");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000037 CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
38 "cert-dcl54-cpp");
39 CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
40 "cert-dcl59-cpp");
41 // OOP
42 CheckFactories.registerCheck<MoveConstructorInitCheck>(
43 "cert-oop11-cpp");
Aaron Ballmane4b17652015-10-08 19:54:43 +000044 // ERR
45 CheckFactories.registerCheck<SetLongJmpCheck>(
46 "cert-err52-cpp");
Aaron Ballman43aef4c2015-12-01 14:05:39 +000047 CheckFactories.registerCheck<StaticObjectExceptionCheck>(
48 "cert-err58-cpp");
Aaron Ballman5a786dd2015-11-16 19:17:43 +000049 CheckFactories.registerCheck<ThrownExceptionTypeCheck>(
50 "cert-err60-cpp");
Aaron Ballmana742b842015-10-13 20:42:41 +000051 CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
52 "cert-err61-cpp");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000053
54 // C checkers
55 // DCL
56 CheckFactories.registerCheck<StaticAssertCheck>(
57 "cert-dcl03-c");
Aaron Ballman527a4202016-02-22 16:01:06 +000058 // ENV
59 CheckFactories.registerCheck<CommandProcessorCheck>(
60 "cert-env33-c");
Aaron Ballman611d2e42016-02-19 14:03:20 +000061 // FLP
62 CheckFactories.registerCheck<FloatLoopCounter>(
63 "cert-flp30-c");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000064 // FIO
65 CheckFactories.registerCheck<NonCopyableObjectsCheck>(
66 "cert-fio38-c");
67 }
68};
69
Aaron Ballman1284f042016-01-04 14:31:14 +000070} // namespace cert
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000071
72// Register the MiscTidyModule using this statically initialized variable.
Aaron Ballman1284f042016-01-04 14:31:14 +000073static ClangTidyModuleRegistry::Add<cert::CERTModule>
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000074X("cert-module",
75 "Adds lint checks corresponding to CERT secure coding guidelines.");
76
77// This anchor is used to force the linker to link in the generated object file
78// and thus register the CERTModule.
79volatile int CERTModuleAnchorSource = 0;
80
81} // namespace tidy
82} // namespace clang