10 #include "clang/AST/ASTContext.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 22 ast_matchers::internal::Matcher<ObjCInterfaceDecl>,
Base) {
23 const ObjCInterfaceDecl *InterfaceDecl = Node.getClassInterface();
24 return Base.matches(*InterfaceDecl, Finder,
Builder);
28 ast_matchers::internal::Matcher<ObjCMethodDecl>,
Base) {
30 for (
const auto *I : Node.instance_methods()) {
39 void MissingHashCheck::registerMatchers(MatchFinder *Finder) {
41 if (!getLangOpts().ObjC)
46 hasName(
"isEqual:"), isInstanceMethod(),
47 hasDeclContext(objcImplementationDecl(
48 hasInterface(isDirectlyDerivedFrom(
"NSObject")),
49 unless(hasInstanceMethod(hasName(
"hash"))))
54 void MissingHashCheck::check(
const MatchFinder::MatchResult &Result) {
55 const auto *ID = Result.Nodes.getNodeAs<ObjCImplementationDecl>(
"impl");
56 diag(ID->getLocation(),
"%0 implements -isEqual: without implementing -hash")
CodeCompletionBuilder Builder
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::unique_ptr< GlobalCompilationDatabase > Base
AST_MATCHER_P(CXXMethodDecl, hasCanonicalDecl, ast_matchers::internal::Matcher< CXXMethodDecl >, InnerMatcher)