11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 using namespace clang::ast_matchers;
20 void DefaultArgumentsCheck::registerMatchers(MatchFinder *
Finder) {
22 cxxMethodDecl(anyOf(isOverride(), isVirtual()),
23 hasAnyParameter(parmVarDecl(hasInitializer(expr()))))
28 void DefaultArgumentsCheck::check(
const MatchFinder::MatchResult &
Result) {
29 const auto *MatchedDecl = Result.Nodes.getNodeAs<CXXMethodDecl>(
"Decl");
30 diag(MatchedDecl->getLocation(),
31 "default arguments on virtual or override methods are prohibited");
std::unique_ptr< ast_matchers::MatchFinder > Finder