10 #include "clang/AST/ASTContext.h"
11 #include "clang/AST/DeclObjC.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
20 void DeallocInCategoryCheck::registerMatchers(MatchFinder *Finder) {
26 objcMethodDecl(isInstanceMethod(), hasName(
"dealloc"),
27 hasDeclContext(objcCategoryImplDecl().bind(
"impl")))
32 void DeallocInCategoryCheck::check(
const MatchFinder::MatchResult &Result) {
33 const auto *DeallocDecl = Result.Nodes.getNodeAs<ObjCMethodDecl>(
"dealloc");
34 const auto *CID = Result.Nodes.getNodeAs<ObjCCategoryImplDecl>(
"impl");
35 assert(DeallocDecl !=
nullptr);
36 diag(DeallocDecl->getLocation(),
"category %0 should not implement -dealloc")