10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
12#include "clang/Lex/Preprocessor.h"
21 callee(functionDecl(hasName(
"::pthread_setcanceltype"))),
23 hasArgument(0, isExpandedFromMacro(
"PTHREAD_CANCEL_ASYNCHRONOUS")))
24 .bind(
"setcanceltype"),
29 const MatchFinder::MatchResult &Result) {
30 const auto *MatchedExpr = Result.Nodes.getNodeAs<Expr>(
"setcanceltype");
31 diag(MatchedExpr->getBeginLoc(),
"the cancel type for a pthread should not "
32 "be 'PTHREAD_CANCEL_ASYNCHRONOUS'");
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.