clang-tools  15.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 "AssertEquals.h"
13 #include "AvoidNSErrorInitCheck.h"
14 #include "DeallocInCategoryCheck.h"
16 #include "MissingHashCheck.h"
19 #include "SuperSelfCheck.h"
20 
21 using namespace clang::ast_matchers;
22 
23 namespace clang {
24 namespace tidy {
25 namespace objc {
26 
27 class ObjCModule : public ClangTidyModule {
28 public:
29  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
30  CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
31  "objc-avoid-nserror-init");
32  CheckFactories.registerCheck<AssertEquals>("objc-assert-equals");
33 
34  CheckFactories.registerCheck<DeallocInCategoryCheck>(
35  "objc-dealloc-in-category");
37  "objc-forbidden-subclassing");
38  CheckFactories.registerCheck<MissingHashCheck>(
39  "objc-missing-hash");
41  "objc-nsinvocation-argument-lifetime");
43  "objc-property-declaration");
44  CheckFactories.registerCheck<SuperSelfCheck>(
45  "objc-super-self");
46  }
47 };
48 
49 // Register the ObjCTidyModule using this statically initialized variable.
50 static ClangTidyModuleRegistry::Add<ObjCModule> X(
51  "objc-module",
52  "Adds Objective-C lint checks.");
53 
54 } // namespace objc
55 
56 // This anchor is used to force the linker to link in the generated object file
57 // and thus register the ObjCModule.
58 volatile int ObjCModuleAnchorSource = 0;
59 
60 } // namespace tidy
61 } // 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:29
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:25
clang::tidy::objc::ObjCModule
Definition: ObjCTidyModule.cpp:27
clang::tidy::objc::MissingHashCheck
Finds Objective-C implementations that implement -isEqual: without also appropriately implementing -h...
Definition: MissingHashCheck.h:23
AssertEquals.h
DeallocInCategoryCheck.h
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::ObjCModuleAnchorSource
volatile int ObjCModuleAnchorSource
Definition: ObjCTidyModule.cpp:58
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:85
clang::tidy::objc::AssertEquals
Warn if XCTAssertEqual() or XCTAssertNotEqual() is used with at least one operands of type NSString*.
Definition: AssertEquals.h:24
PropertyDeclarationCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59