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 
9 #include "../ClangTidy.h"
10 #include "../ClangTidyModule.h"
11 #include "../ClangTidyModuleRegistry.h"
12 #include "AvoidNSErrorInitCheck.h"
13 #include "AvoidSpinlockCheck.h"
14 #include "ForbiddenSubclassingCheck.h"
15 #include "PropertyDeclarationCheck.h"
16 
17 using namespace clang::ast_matchers;
18 
19 namespace clang {
20 namespace tidy {
21 namespace objc {
22 
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<AvoidSpinlockCheck>(
29         "objc-avoid-spinlock");
30     CheckFactories.registerCheck<ForbiddenSubclassingCheck>(
31         "objc-forbidden-subclassing");
32     CheckFactories.registerCheck<PropertyDeclarationCheck>(
33         "objc-property-declaration");
34   }
35 };
36 
37 // Register the ObjCTidyModule using this statically initialized variable.
38 static ClangTidyModuleRegistry::Add<ObjCModule> X(
39     "objc-module",
40     "Adds Objective-C lint checks.");
41 
42 } // namespace objc
43 
44 // This anchor is used to force the linker to link in the generated object file
45 // and thus register the ObjCModule.
46 volatile int ObjCModuleAnchorSource = 0;
47 
48 } // namespace tidy
49 } // namespace clang
50