blob: 4e0a6ed24d554e857a5e3379c947091ee9cb9852 [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 Ballmane4b17652015-10-08 19:54:43 +000019#include "SetLongJmpCheck.h"
Aaron Ballman43aef4c2015-12-01 14:05:39 +000020#include "StaticObjectExceptionCheck.h"
Aaron Ballman5a786dd2015-11-16 19:17:43 +000021#include "ThrownExceptionTypeCheck.h"
Aaron Ballman46bc3042015-10-05 20:08:59 +000022#include "VariadicFunctionDefCheck.h"
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000023
24namespace clang {
25namespace tidy {
Aaron Ballman1284f042016-01-04 14:31:14 +000026namespace cert {
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000027
28class CERTModule : public ClangTidyModule {
29public:
30 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
31 // C++ checkers
32 // DCL
Aaron Ballman46bc3042015-10-05 20:08:59 +000033 CheckFactories.registerCheck<VariadicFunctionDefCheck>(
34 "cert-dcl50-cpp");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000035 CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
36 "cert-dcl54-cpp");
37 CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
38 "cert-dcl59-cpp");
39 // OOP
40 CheckFactories.registerCheck<MoveConstructorInitCheck>(
41 "cert-oop11-cpp");
Aaron Ballmane4b17652015-10-08 19:54:43 +000042 // ERR
43 CheckFactories.registerCheck<SetLongJmpCheck>(
44 "cert-err52-cpp");
Aaron Ballman43aef4c2015-12-01 14:05:39 +000045 CheckFactories.registerCheck<StaticObjectExceptionCheck>(
46 "cert-err58-cpp");
Aaron Ballman5a786dd2015-11-16 19:17:43 +000047 CheckFactories.registerCheck<ThrownExceptionTypeCheck>(
48 "cert-err60-cpp");
Aaron Ballmana742b842015-10-13 20:42:41 +000049 CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
50 "cert-err61-cpp");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000051
52 // C checkers
53 // DCL
54 CheckFactories.registerCheck<StaticAssertCheck>(
55 "cert-dcl03-c");
56
57 // FIO
58 CheckFactories.registerCheck<NonCopyableObjectsCheck>(
59 "cert-fio38-c");
60 }
61};
62
Aaron Ballman1284f042016-01-04 14:31:14 +000063} // namespace cert
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000064
65// Register the MiscTidyModule using this statically initialized variable.
Aaron Ballman1284f042016-01-04 14:31:14 +000066static ClangTidyModuleRegistry::Add<cert::CERTModule>
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000067X("cert-module",
68 "Adds lint checks corresponding to CERT secure coding guidelines.");
69
70// This anchor is used to force the linker to link in the generated object file
71// and thus register the CERTModule.
72volatile int CERTModuleAnchorSource = 0;
73
74} // namespace tidy
75} // namespace clang