11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
22 if (!getLangOpts().ObjC)
25 Finder->addMatcher(objcMessageExpr(hasSelector(
"init"),
26 hasReceiverType(asString(
"NSError *")))
31 void AvoidNSErrorInitCheck::check(
const MatchFinder::MatchResult &
Result) {
32 const auto *MatchedExpr =
33 Result.Nodes.getNodeAs<ObjCMessageExpr>(
"nserrorInit");
34 diag(MatchedExpr->getBeginLoc(),
35 "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to " 36 "create a new NSError");
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//