brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · ed65cd1 Raw
71 lines · cpp
1//===----------------------------------------------------------------------===//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-exception6//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 "PreferStaticOverAnonymousNamespaceCheck.h"20#include "TwineLocalCheck.h"21#include "UseNewMLIROpBuilderCheck.h"22#include "UseRangesCheck.h"23 24namespace clang::tidy {25namespace llvm_check {26 27class LLVMModule : public ClangTidyModule {28public:29  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {30    CheckFactories.registerCheck<readability::ElseAfterReturnCheck>(31        "llvm-else-after-return");32    CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");33    CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");34    CheckFactories.registerCheck<readability::NamespaceCommentCheck>(35        "llvm-namespace-comment");36    CheckFactories.registerCheck<PreferIsaOrDynCastInConditionalsCheck>(37        "llvm-prefer-isa-or-dyn-cast-in-conditionals");38    CheckFactories.registerCheck<PreferRegisterOverUnsignedCheck>(39        "llvm-prefer-register-over-unsigned");40    CheckFactories.registerCheck<PreferStaticOverAnonymousNamespaceCheck>(41        "llvm-prefer-static-over-anonymous-namespace");42    CheckFactories.registerCheck<readability::QualifiedAutoCheck>(43        "llvm-qualified-auto");44    CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");45    CheckFactories.registerCheck<UseNewMlirOpBuilderCheck>(46        "llvm-use-new-mlir-op-builder");47    CheckFactories.registerCheck<UseRangesCheck>("llvm-use-ranges");48  }49 50  ClangTidyOptions getModuleOptions() override {51    ClangTidyOptions Options;52    Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";53    Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";54    Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =55        "false";56    return Options;57  }58};59 60// Register the LLVMTidyModule using this statically initialized variable.61static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module",62                                                  "Adds LLVM lint checks.");63 64} // namespace llvm_check65 66// This anchor is used to force the linker to link in the generated object file67// and thus register the LLVMModule.68volatile int LLVMModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage)69 70} // namespace clang::tidy71