11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 using namespace clang::ast_matchers;
19 void ProTypeConstCastCheck::registerMatchers(MatchFinder *
Finder) {
20 if (!getLangOpts().CPlusPlus)
23 Finder->addMatcher(cxxConstCastExpr().bind(
"cast"),
this);
26 void ProTypeConstCastCheck::check(
const MatchFinder::MatchResult &
Result) {
27 const auto *MatchedCast = Result.Nodes.getNodeAs<CXXConstCastExpr>(
"cast");
28 diag(MatchedCast->getOperatorLoc(),
"do not use const_cast");
std::unique_ptr< ast_matchers::MatchFinder > Finder