10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
20 ast_matchers::internal::Matcher<ObjCInterfaceDecl>, Base) {
21 const ObjCInterfaceDecl *InterfaceDecl =
Node.getClassInterface();
22 return Base.matches(*InterfaceDecl, Finder,
Builder);
26 ast_matchers::internal::Matcher<ObjCMethodDecl>, Base) {
28 for (
const auto *I :
Node.instance_methods()) {
29 if (Base.matches(*I, Finder,
Builder))
40 hasName(
"isEqual:"), isInstanceMethod(),
41 hasDeclContext(objcImplementationDecl(
42 hasInterface(isDirectlyDerivedFrom(
"NSObject")),
43 unless(hasInstanceMethod(hasName(
"hash"))))
49 const auto *
ID = Result.Nodes.getNodeAs<ObjCImplementationDecl>(
"impl");
50 diag(
ID->getLocation(),
"%0 implements -isEqual: without implementing -hash")
CodeCompletionBuilder Builder
::clang::DynTypedNode Node
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
AST_MATCHER_P(UserDefinedLiteral, hasLiteral, clang::ast_matchers::internal::Matcher< Expr >, InnerMatcher)