17 void DefaultArgumentsDeclarationsCheck::registerMatchers(MatchFinder *Finder) {
19 Finder->addMatcher(parmVarDecl(hasDefaultArgument()).bind(
"decl"),
this);
22 void DefaultArgumentsDeclarationsCheck::check(
23 const MatchFinder::MatchResult &Result) {
24 const auto *D = Result.Nodes.getNodeAs<ParmVarDecl>(
"decl");
28 SourceRange DefaultArgRange = D->getDefaultArgRange();
30 if (DefaultArgRange.getEnd() != D->getEndLoc())
33 if (DefaultArgRange.getBegin().isMacroID()) {
34 diag(D->getBeginLoc(),
35 "declaring a parameter with a default argument is disallowed");
39 SourceLocation StartLocation =
40 D->getName().empty() ? D->getBeginLoc() : D->getLocation();
42 SourceRange RemovalRange(
43 Lexer::getLocForEndOfToken(StartLocation, 0, *Result.SourceManager,
44 Result.Context->getLangOpts()),
45 DefaultArgRange.getEnd());
47 diag(D->getBeginLoc(),
48 "declaring a parameter with a default argument is disallowed")
49 << D << FixItHint::CreateRemoval(RemovalRange);
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//