Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 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" |
Aaron Ballman | a742b84 | 2015-10-13 20:42:41 +0000 | [diff] [blame] | 18 | #include "../misc/ThrowByValueCatchByReferenceCheck.h" |
Aaron Ballman | e4b1765 | 2015-10-08 19:54:43 +0000 | [diff] [blame] | 19 | #include "SetLongJmpCheck.h" |
Aaron Ballman | 5a786dd | 2015-11-16 19:17:43 +0000 | [diff] [blame] | 20 | #include "ThrownExceptionTypeCheck.h" |
Aaron Ballman | 46bc304 | 2015-10-05 20:08:59 +0000 | [diff] [blame] | 21 | #include "VariadicFunctionDefCheck.h" |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 22 | |
| 23 | namespace clang { |
| 24 | namespace tidy { |
| 25 | namespace CERT { |
| 26 | |
| 27 | class CERTModule : public ClangTidyModule { |
| 28 | public: |
| 29 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
| 30 | // C++ checkers |
| 31 | // DCL |
Aaron Ballman | 46bc304 | 2015-10-05 20:08:59 +0000 | [diff] [blame] | 32 | CheckFactories.registerCheck<VariadicFunctionDefCheck>( |
| 33 | "cert-dcl50-cpp"); |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 34 | 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 Ballman | e4b1765 | 2015-10-08 19:54:43 +0000 | [diff] [blame] | 41 | // ERR |
| 42 | CheckFactories.registerCheck<SetLongJmpCheck>( |
| 43 | "cert-err52-cpp"); |
Aaron Ballman | 5a786dd | 2015-11-16 19:17:43 +0000 | [diff] [blame] | 44 | CheckFactories.registerCheck<ThrownExceptionTypeCheck>( |
| 45 | "cert-err60-cpp"); |
Aaron Ballman | a742b84 | 2015-10-13 20:42:41 +0000 | [diff] [blame] | 46 | CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>( |
| 47 | "cert-err61-cpp"); |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 48 | |
| 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. |
| 63 | static ClangTidyModuleRegistry::Add<CERT::CERTModule> |
| 64 | X("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. |
| 69 | volatile int CERTModuleAnchorSource = 0; |
| 70 | |
| 71 | } // namespace tidy |
| 72 | } // namespace clang |