10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
18 Finder->addMatcher(cxxReinterpretCastExpr().bind(
"cast"),
this);
22 const MatchFinder::MatchResult &Result) {
23 const auto *MatchedCast =
24 Result.Nodes.getNodeAs<CXXReinterpretCastExpr>(
"cast");
25 diag(MatchedCast->getOperatorLoc(),
"do not use reinterpret_cast");
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.