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