10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
18 Finder->addMatcher(cxxConstCastExpr().bind(
"cast"),
this);
22 const auto *MatchedCast = Result.Nodes.getNodeAs<CXXConstCastExpr>(
"cast");
23 diag(MatchedCast->getOperatorLoc(),
"do not use const_cast");
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.