Gabor Horvath | 829e75a | 2017-07-14 12:15:55 +0000 | [diff] [blame] | 1 | //===--- BugproneTidyModule.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" |
Gabor Horvath | d984e33 | 2017-11-17 12:23:30 +0000 | [diff] [blame] | 13 | #include "CopyConstructorInitCheck.h" |
Gabor Horvath | 0b16c10 | 2017-08-10 13:30:30 +0000 | [diff] [blame] | 14 | #include "IntegerDivisionCheck.h" |
Adam Balogh | 2079def | 2017-11-23 12:26:28 +0000 | [diff] [blame] | 15 | #include "MisplacedOperatorInStrlenInAllocCheck.h" |
Alexander Kornienko | a3251bf | 2017-11-23 13:49:14 +0000 | [diff] [blame^] | 16 | #include "StringConstructorCheck.h" |
Gabor Horvath | 829e75a | 2017-07-14 12:15:55 +0000 | [diff] [blame] | 17 | #include "SuspiciousMemsetUsageCheck.h" |
Gabor Horvath | 46a9db4 | 2017-07-14 12:20:19 +0000 | [diff] [blame] | 18 | #include "UndefinedMemoryManipulationCheck.h" |
Gabor Horvath | 829e75a | 2017-07-14 12:15:55 +0000 | [diff] [blame] | 19 | |
| 20 | namespace clang { |
| 21 | namespace tidy { |
| 22 | namespace bugprone { |
| 23 | |
| 24 | class BugproneModule : public ClangTidyModule { |
| 25 | public: |
| 26 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
Gabor Horvath | d984e33 | 2017-11-17 12:23:30 +0000 | [diff] [blame] | 27 | CheckFactories.registerCheck<CopyConstructorInitCheck>( |
Gabor Horvath | 024d0b3 | 2017-11-17 12:28:58 +0000 | [diff] [blame] | 28 | "bugprone-copy-constructor-init"); |
Gabor Horvath | 0b16c10 | 2017-08-10 13:30:30 +0000 | [diff] [blame] | 29 | CheckFactories.registerCheck<IntegerDivisionCheck>( |
| 30 | "bugprone-integer-division"); |
Adam Balogh | 2079def | 2017-11-23 12:26:28 +0000 | [diff] [blame] | 31 | CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>( |
| 32 | "bugprone-misplaced-operator-in-strlen-in-alloc"); |
Alexander Kornienko | a3251bf | 2017-11-23 13:49:14 +0000 | [diff] [blame^] | 33 | CheckFactories.registerCheck<StringConstructorCheck>( |
| 34 | "bugprone-string-constructor"); |
Gabor Horvath | 829e75a | 2017-07-14 12:15:55 +0000 | [diff] [blame] | 35 | CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>( |
| 36 | "bugprone-suspicious-memset-usage"); |
Gabor Horvath | 46a9db4 | 2017-07-14 12:20:19 +0000 | [diff] [blame] | 37 | CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>( |
| 38 | "bugprone-undefined-memory-manipulation"); |
Gabor Horvath | 829e75a | 2017-07-14 12:15:55 +0000 | [diff] [blame] | 39 | } |
| 40 | }; |
| 41 | |
| 42 | } // namespace bugprone |
| 43 | |
| 44 | // Register the BugproneTidyModule using this statically initialized variable. |
| 45 | static ClangTidyModuleRegistry::Add<bugprone::BugproneModule> |
| 46 | X("bugprone-module", "Adds checks for bugprone code constructs."); |
| 47 | |
| 48 | // This anchor is used to force the linker to link in the generated object file |
| 49 | // and thus register the BugproneModule. |
| 50 | volatile int BugproneModuleAnchorSource = 0; |
| 51 | |
| 52 | } // namespace tidy |
| 53 | } // namespace clang |