LLVMTidyModule.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include "../ClangTidy.h"
  9. #include "../ClangTidyModule.h"
  10. #include "../ClangTidyModuleRegistry.h"
  11. #include "../readability/ElseAfterReturnCheck.h"
  12. #include "../readability/NamespaceCommentCheck.h"
  13. #include "../readability/QualifiedAutoCheck.h"
  14. #include "HeaderGuardCheck.h"
  15. #include "IncludeOrderCheck.h"
  16. #include "PreferIsaOrDynCastInConditionalsCheck.h"
  17. #include "PreferRegisterOverUnsignedCheck.h"
  18. #include "TwineLocalCheck.h"
  19. namespace clang::tidy {
  20. namespace llvm_check {
  21. class LLVMModule : public ClangTidyModule {
  22. public:
  23. void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
  24. CheckFactories.registerCheck<readability::ElseAfterReturnCheck>(
  25. "llvm-else-after-return");
  26. CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
  27. CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
  28. CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
  29. "llvm-namespace-comment");
  30. CheckFactories.registerCheck<PreferIsaOrDynCastInConditionalsCheck>(
  31. "llvm-prefer-isa-or-dyn-cast-in-conditionals");
  32. CheckFactories.registerCheck<PreferRegisterOverUnsignedCheck>(
  33. "llvm-prefer-register-over-unsigned");
  34. CheckFactories.registerCheck<readability::QualifiedAutoCheck>(
  35. "llvm-qualified-auto");
  36. CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");
  37. }
  38. ClangTidyOptions getModuleOptions() override {
  39. ClangTidyOptions Options;
  40. Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";
  41. Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";
  42. Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
  43. "false";
  44. return Options;
  45. }
  46. };
  47. // Register the LLVMTidyModule using this statically initialized variable.
  48. static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module",
  49. "Adds LLVM lint checks.");
  50. } // namespace llvm_check
  51. // This anchor is used to force the linker to link in the generated object file
  52. // and thus register the LLVMModule.
  53. volatile int LLVMModuleAnchorSource = 0;
  54. } // namespace clang::tidy