10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
18 Finder->addMatcher(objcMessageExpr(hasSelector(
"init"),
19 hasReceiverType(asString(
"NSError *")))
25 const auto *MatchedExpr =
26 Result.Nodes.getNodeAs<ObjCMessageExpr>(
"nserrorInit");
27 diag(MatchedExpr->getBeginLoc(),
28 "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to "
29 "create a new NSError");
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.