clang-tools  14.0.0git
ObjCTidyModule.cpp
Go to the documentation of this file.
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 "DeallocInCategoryCheck.h"
15 #include "MissingHashCheck.h"
18 #include "SuperSelfCheck.h"
19 
20 using namespace clang::ast_matchers;
21 
22 namespace clang {
23 namespace tidy {
24 namespace objc {
25 
26 class ObjCModule : public ClangTidyModule {
27 public:
28  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
29  CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
30  "objc-avoid-nserror-init");
31  CheckFactories.registerCheck<DeallocInCategoryCheck>(
32  "objc-dealloc-in-category");
34  "objc-forbidden-subclassing");
35  CheckFactories.registerCheck<MissingHashCheck>(
36  "objc-missing-hash");
38  "objc-nsinvocation-argument-lifetime");
40  "objc-property-declaration");
41  CheckFactories.registerCheck<SuperSelfCheck>(
42  "objc-super-self");
43  }
44 };
45 
46 // Register the ObjCTidyModule using this statically initialized variable.
47 static ClangTidyModuleRegistry::Add<ObjCModule> X(
48  "objc-module",
49  "Adds Objective-C lint checks.");
50 
51 } // namespace objc
52 
53 // This anchor is used to force the linker to link in the generated object file
54 // and thus register the ObjCModule.
55 volatile int ObjCModuleAnchorSource = 0;
56 
57 } // namespace tidy
58 } // namespace clang
NSInvocationArgumentLifetimeCheck.h
clang::tidy::objc::ObjCModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Definition: ObjCTidyModule.cpp:28
ForbiddenSubclassingCheck.h
clang::ast_matchers
Definition: AbseilMatcher.h:14
SuperSelfCheck.h
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:28
X
int X
Definition: LSPBinderTests.cpp:25
clang::tidy::objc::PropertyDeclarationCheck
Definition: PropertyDeclarationCheck.h:26
clang::tidy::objc::AvoidNSErrorInitCheck
Finds usages of -[NSError init].
Definition: AvoidNSErrorInitCheck.h:23
MissingHashCheck.h
clang::tidy::objc::SuperSelfCheck
Finds invocations of -self on super instances in initializers of subclasses of NSObject and recommend...
Definition: SuperSelfCheck.h:23
clang::tidy::objc::ForbiddenSubclassingCheck
Finds Objective-C classes which have a superclass which is documented to not support subclassing.
Definition: ForbiddenSubclassingCheck.h:26
clang::tidy::objc::ObjCModule
Definition: ObjCTidyModule.cpp:26
clang::tidy::objc::MissingHashCheck
Finds Objective-C implementations that implement -isEqual: without also appropriately implementing -h...
Definition: MissingHashCheck.h:23
DeallocInCategoryCheck.h
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::ObjCModuleAnchorSource
volatile int ObjCModuleAnchorSource
Definition: ObjCTidyModule.cpp:55
clang::tidy::objc::NSInvocationArgumentLifetimeCheck
Finds calls to NSInvocation methods under ARC that don't have proper argument object lifetimes.
Definition: NSInvocationArgumentLifetimeCheck.h:24
AvoidNSErrorInitCheck.h
clang::tidy::objc::DeallocInCategoryCheck
Finds implementations of -dealloc in Objective-C categories.
Definition: DeallocInCategoryCheck.h:24
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:81
PropertyDeclarationCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59