11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
21 Finder->addMatcher(objcMessageExpr(hasSelector(
"init"),
22 hasReceiverType(asString(
"NSError *")))
27 void AvoidNSErrorInitCheck::check(
const MatchFinder::MatchResult &Result) {
28 const auto *MatchedExpr =
29 Result.Nodes.getNodeAs<ObjCMessageExpr>(
"nserrorInit");
30 diag(MatchedExpr->getLocStart(),
31 "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to " 32 "create a new NSError");