ObjCTidyModule.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //===--- ObjCTidyModule.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 "AssertEquals.h"
  12. #include "AvoidNSErrorInitCheck.h"
  13. #include "DeallocInCategoryCheck.h"
  14. #include "ForbiddenSubclassingCheck.h"
  15. #include "MissingHashCheck.h"
  16. #include "NSDateFormatterCheck.h"
  17. #include "NSInvocationArgumentLifetimeCheck.h"
  18. #include "PropertyDeclarationCheck.h"
  19. #include "SuperSelfCheck.h"
  20. using namespace clang::ast_matchers;
  21. namespace clang::tidy {
  22. namespace objc {
  23. class ObjCModule : public ClangTidyModule {
  24. public:
  25. void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
  26. CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
  27. "objc-avoid-nserror-init");
  28. CheckFactories.registerCheck<AssertEquals>("objc-assert-equals");
  29. CheckFactories.registerCheck<DeallocInCategoryCheck>(
  30. "objc-dealloc-in-category");
  31. CheckFactories.registerCheck<ForbiddenSubclassingCheck>(
  32. "objc-forbidden-subclassing");
  33. CheckFactories.registerCheck<MissingHashCheck>(
  34. "objc-missing-hash");
  35. CheckFactories.registerCheck<NSDateFormatterCheck>("objc-nsdate-formatter");
  36. CheckFactories.registerCheck<NSInvocationArgumentLifetimeCheck>(
  37. "objc-nsinvocation-argument-lifetime");
  38. CheckFactories.registerCheck<PropertyDeclarationCheck>(
  39. "objc-property-declaration");
  40. CheckFactories.registerCheck<SuperSelfCheck>(
  41. "objc-super-self");
  42. }
  43. };
  44. // Register the ObjCTidyModule using this statically initialized variable.
  45. static ClangTidyModuleRegistry::Add<ObjCModule> X(
  46. "objc-module",
  47. "Adds Objective-C lint checks.");
  48. } // namespace objc
  49. // This anchor is used to force the linker to link in the generated object file
  50. // and thus register the ObjCModule.
  51. volatile int ObjCModuleAnchorSource = 0;
  52. } // namespace clang::tidy