blob: a79774499eb822e45200f069e62bc33a09bb5d94 [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 Ballman5a786dd2015-11-16 19:17:43 +000020#include "ThrownExceptionTypeCheck.h"
Aaron Ballman46bc3042015-10-05 20:08:59 +000021#include "VariadicFunctionDefCheck.h"
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000022
23namespace clang {
24namespace tidy {
25namespace CERT {
26
27class CERTModule : public ClangTidyModule {
28public:
29 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
30 // C++ checkers
31 // DCL
Aaron Ballman46bc3042015-10-05 20:08:59 +000032 CheckFactories.registerCheck<VariadicFunctionDefCheck>(
33 "cert-dcl50-cpp");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000034 CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
35 "cert-dcl54-cpp");
36 CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
37 "cert-dcl59-cpp");
38 // OOP
39 CheckFactories.registerCheck<MoveConstructorInitCheck>(
40 "cert-oop11-cpp");
Aaron Ballmane4b17652015-10-08 19:54:43 +000041 // ERR
42 CheckFactories.registerCheck<SetLongJmpCheck>(
43 "cert-err52-cpp");
Aaron Ballman5a786dd2015-11-16 19:17:43 +000044 CheckFactories.registerCheck<ThrownExceptionTypeCheck>(
45 "cert-err60-cpp");
Aaron Ballmana742b842015-10-13 20:42:41 +000046 CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
47 "cert-err61-cpp");
Aaron Ballmanea2f90c2015-10-02 13:27:19 +000048
49 // C checkers
50 // DCL
51 CheckFactories.registerCheck<StaticAssertCheck>(
52 "cert-dcl03-c");
53
54 // FIO
55 CheckFactories.registerCheck<NonCopyableObjectsCheck>(
56 "cert-fio38-c");
57 }
58};
59
60} // namespace misc
61
62// Register the MiscTidyModule using this statically initialized variable.
63static ClangTidyModuleRegistry::Add<CERT::CERTModule>
64X("cert-module",
65 "Adds lint checks corresponding to CERT secure coding guidelines.");
66
67// This anchor is used to force the linker to link in the generated object file
68// and thus register the CERTModule.
69volatile int CERTModuleAnchorSource = 0;
70
71} // namespace tidy
72} // namespace clang