1 //===--- LLVMTidyModule.cpp - clang-tidy ----------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "../ClangTidy.h" 10 #include "../ClangTidyModule.h" 11 #include "../ClangTidyModuleRegistry.h" 12 #include "../readability/ElseAfterReturnCheck.h" 13 #include "../readability/NamespaceCommentCheck.h" 14 #include "../readability/QualifiedAutoCheck.h" 15 #include "HeaderGuardCheck.h" 16 #include "IncludeOrderCheck.h" 17 #include "PreferIsaOrDynCastInConditionalsCheck.h" 18 #include "PreferRegisterOverUnsignedCheck.h" 19 #include "TwineLocalCheck.h" 20 21 namespace clang { 22 namespace tidy { 23 namespace llvm_check { 24 25 class LLVMModule : public ClangTidyModule { 26 public: addCheckFactories(ClangTidyCheckFactories & CheckFactories)27 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { 28 CheckFactories.registerCheck<readability::ElseAfterReturnCheck>( 29 "llvm-else-after-return"); 30 CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard"); 31 CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order"); 32 CheckFactories.registerCheck<readability::NamespaceCommentCheck>( 33 "llvm-namespace-comment"); 34 CheckFactories.registerCheck<PreferIsaOrDynCastInConditionalsCheck>( 35 "llvm-prefer-isa-or-dyn-cast-in-conditionals"); 36 CheckFactories.registerCheck<PreferRegisterOverUnsignedCheck>( 37 "llvm-prefer-register-over-unsigned"); 38 CheckFactories.registerCheck<readability::QualifiedAutoCheck>( 39 "llvm-qualified-auto"); 40 CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local"); 41 } 42 getModuleOptions()43 ClangTidyOptions getModuleOptions() override { 44 ClangTidyOptions Options; 45 Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0"; 46 Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0"; 47 Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] = 48 "0"; 49 return Options; 50 } 51 }; 52 53 // Register the LLVMTidyModule using this statically initialized variable. 54 static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module", 55 "Adds LLVM lint checks."); 56 57 } // namespace llvm_check 58 59 // This anchor is used to force the linker to link in the generated object file 60 // and thus register the LLVMModule. 61 volatile int LLVMModuleAnchorSource = 0; 62 63 } // namespace tidy 64 } // namespace clang 65