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