Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 1 | //===--- ModernizeTidyModule.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" |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 13 | #include "LoopConvertCheck.h" |
Angel Garcia Gomez | 26fd0e8 | 2015-09-29 09:36:41 +0000 | [diff] [blame^] | 14 | #include "MakeUniqueCheck.h" |
Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 15 | #include "PassByValueCheck.h" |
Angel Garcia Gomez | 1901671 | 2015-08-25 13:03:43 +0000 | [diff] [blame] | 16 | #include "ReplaceAutoPtrCheck.h" |
Alexander Kornienko | 0ed6c47 | 2015-08-31 13:17:43 +0000 | [diff] [blame] | 17 | #include "ShrinkToFitCheck.h" |
Angel Garcia Gomez | 5b9d33a | 2015-08-21 15:08:51 +0000 | [diff] [blame] | 18 | #include "UseAutoCheck.h" |
Alexander Kornienko | 1b7bf7a | 2015-08-19 22:21:37 +0000 | [diff] [blame] | 19 | #include "UseNullptrCheck.h" |
Alexander Kornienko | 0ed6c47 | 2015-08-31 13:17:43 +0000 | [diff] [blame] | 20 | #include "UseOverrideCheck.h" |
Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace clang::ast_matchers; |
| 23 | |
| 24 | namespace clang { |
| 25 | namespace tidy { |
| 26 | namespace modernize { |
| 27 | |
| 28 | class ModernizeModule : public ClangTidyModule { |
| 29 | public: |
| 30 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 31 | CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert"); |
Angel Garcia Gomez | 26fd0e8 | 2015-09-29 09:36:41 +0000 | [diff] [blame^] | 32 | CheckFactories.registerCheck<MakeUniqueCheck>( |
| 33 | "modernize-make-unique"); |
Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 34 | CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value"); |
Angel Garcia Gomez | 1901671 | 2015-08-25 13:03:43 +0000 | [diff] [blame] | 35 | CheckFactories.registerCheck<ReplaceAutoPtrCheck>( |
| 36 | "modernize-replace-auto-ptr"); |
Alexander Kornienko | 0ed6c47 | 2015-08-31 13:17:43 +0000 | [diff] [blame] | 37 | CheckFactories.registerCheck<ShrinkToFitCheck>("modernize-shrink-to-fit"); |
Angel Garcia Gomez | 5b9d33a | 2015-08-21 15:08:51 +0000 | [diff] [blame] | 38 | CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto"); |
Alexander Kornienko | 1b7bf7a | 2015-08-19 22:21:37 +0000 | [diff] [blame] | 39 | CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr"); |
Alexander Kornienko | 0ed6c47 | 2015-08-31 13:17:43 +0000 | [diff] [blame] | 40 | CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override"); |
Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | ClangTidyOptions getModuleOptions() override { |
| 44 | ClangTidyOptions Options; |
| 45 | auto &Opts = Options.CheckOptions; |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 46 | Opts["modernize-loop-convert.MinConfidence"] = "reasonable"; |
Angel Garcia Gomez | 8535c6c | 2015-09-24 17:02:19 +0000 | [diff] [blame] | 47 | Opts["modernize-loop-convert.NamingStyle"] = "CamelCase"; |
Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 48 | Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google". |
Angel Garcia Gomez | 1901671 | 2015-08-25 13:03:43 +0000 | [diff] [blame] | 49 | Opts["modernize-replace-auto-ptr.IncludeStyle"] = "llvm"; // Also: "google". |
Alexander Kornienko | 1b7bf7a | 2015-08-19 22:21:37 +0000 | [diff] [blame] | 50 | |
| 51 | // Comma-separated list of macros that behave like NULL. |
| 52 | Opts["modernize-use-nullptr.NullMacros"] = "NULL"; |
Alexander Kornienko | fc65086 | 2015-08-14 13:17:11 +0000 | [diff] [blame] | 53 | return Options; |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | // Register the ModernizeTidyModule using this statically initialized variable. |
| 58 | static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module", |
| 59 | "Add modernize checks."); |
| 60 | |
| 61 | } // namespace modernize |
| 62 | |
| 63 | // This anchor is used to force the linker to link in the generated object file |
| 64 | // and thus register the ModernizeModule. |
| 65 | volatile int ModernizeModuleAnchorSource = 0; |
| 66 | |
| 67 | } // namespace tidy |
| 68 | } // namespace clang |