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