32 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "DefaultArgumentsCallsCheck.h"10 11using namespace clang::ast_matchers;12 13namespace clang::tidy::fuchsia {14 15void DefaultArgumentsCallsCheck::registerMatchers(MatchFinder *Finder) {16 // Calling a function which uses default arguments is disallowed.17 Finder->addMatcher(cxxDefaultArgExpr().bind("stmt"), this);18}19 20void DefaultArgumentsCallsCheck::check(const MatchFinder::MatchResult &Result) {21 const auto *S = Result.Nodes.getNodeAs<CXXDefaultArgExpr>("stmt");22 if (!S)23 return;24 25 diag(S->getUsedLocation(),26 "calling a function that uses a default argument is disallowed");27 diag(S->getParam()->getBeginLoc(), "default parameter was declared here",28 DiagnosticIDs::Note);29}30 31} // namespace clang::tidy::fuchsia32