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 | 611d2e4 | 2016-02-19 14:03:20 +0000 | [diff] [blame^] | 19 | #include "FloatLoopCounter.h" |
Aaron Ballman | e4b1765 | 2015-10-08 19:54:43 +0000 | [diff] [blame] | 20 | #include "SetLongJmpCheck.h" |
Aaron Ballman | 43aef4c | 2015-12-01 14:05:39 +0000 | [diff] [blame] | 21 | #include "StaticObjectExceptionCheck.h" |
Aaron Ballman | 5a786dd | 2015-11-16 19:17:43 +0000 | [diff] [blame] | 22 | #include "ThrownExceptionTypeCheck.h" |
Aaron Ballman | 46bc304 | 2015-10-05 20:08:59 +0000 | [diff] [blame] | 23 | #include "VariadicFunctionDefCheck.h" |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 24 | |
| 25 | namespace clang { |
| 26 | namespace tidy { |
Aaron Ballman | 1284f04 | 2016-01-04 14:31:14 +0000 | [diff] [blame] | 27 | namespace cert { |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 28 | |
| 29 | class CERTModule : public ClangTidyModule { |
| 30 | public: |
| 31 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
| 32 | // C++ checkers |
| 33 | // DCL |
Aaron Ballman | 46bc304 | 2015-10-05 20:08:59 +0000 | [diff] [blame] | 34 | CheckFactories.registerCheck<VariadicFunctionDefCheck>( |
| 35 | "cert-dcl50-cpp"); |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 36 | CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>( |
| 37 | "cert-dcl54-cpp"); |
| 38 | CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>( |
| 39 | "cert-dcl59-cpp"); |
| 40 | // OOP |
| 41 | CheckFactories.registerCheck<MoveConstructorInitCheck>( |
| 42 | "cert-oop11-cpp"); |
Aaron Ballman | e4b1765 | 2015-10-08 19:54:43 +0000 | [diff] [blame] | 43 | // ERR |
| 44 | CheckFactories.registerCheck<SetLongJmpCheck>( |
| 45 | "cert-err52-cpp"); |
Aaron Ballman | 43aef4c | 2015-12-01 14:05:39 +0000 | [diff] [blame] | 46 | CheckFactories.registerCheck<StaticObjectExceptionCheck>( |
| 47 | "cert-err58-cpp"); |
Aaron Ballman | 5a786dd | 2015-11-16 19:17:43 +0000 | [diff] [blame] | 48 | CheckFactories.registerCheck<ThrownExceptionTypeCheck>( |
| 49 | "cert-err60-cpp"); |
Aaron Ballman | a742b84 | 2015-10-13 20:42:41 +0000 | [diff] [blame] | 50 | CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>( |
| 51 | "cert-err61-cpp"); |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 52 | |
| 53 | // C checkers |
| 54 | // DCL |
| 55 | CheckFactories.registerCheck<StaticAssertCheck>( |
| 56 | "cert-dcl03-c"); |
Aaron Ballman | 611d2e4 | 2016-02-19 14:03:20 +0000 | [diff] [blame^] | 57 | // FLP |
| 58 | CheckFactories.registerCheck<FloatLoopCounter>( |
| 59 | "cert-flp30-c"); |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 60 | // FIO |
| 61 | CheckFactories.registerCheck<NonCopyableObjectsCheck>( |
| 62 | "cert-fio38-c"); |
| 63 | } |
| 64 | }; |
| 65 | |
Aaron Ballman | 1284f04 | 2016-01-04 14:31:14 +0000 | [diff] [blame] | 66 | } // namespace cert |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 67 | |
| 68 | // Register the MiscTidyModule using this statically initialized variable. |
Aaron Ballman | 1284f04 | 2016-01-04 14:31:14 +0000 | [diff] [blame] | 69 | static ClangTidyModuleRegistry::Add<cert::CERTModule> |
Aaron Ballman | ea2f90c | 2015-10-02 13:27:19 +0000 | [diff] [blame] | 70 | X("cert-module", |
| 71 | "Adds lint checks corresponding to CERT secure coding guidelines."); |
| 72 | |
| 73 | // This anchor is used to force the linker to link in the generated object file |
| 74 | // and thus register the CERTModule. |
| 75 | volatile int CERTModuleAnchorSource = 0; |
| 76 | |
| 77 | } // namespace tidy |
| 78 | } // namespace clang |