1 //===--- DefaultArgumentsCallsCheck.cpp - clang-tidy-----------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #include "DefaultArgumentsCallsCheck.h"
11 using namespace clang::ast_matchers
;
13 namespace clang::tidy::fuchsia
{
15 void DefaultArgumentsCallsCheck::registerMatchers(MatchFinder
*Finder
) {
16 // Calling a function which uses default arguments is disallowed.
17 Finder
->addMatcher(cxxDefaultArgExpr().bind("stmt"), this);
20 void DefaultArgumentsCallsCheck::check(const MatchFinder::MatchResult
&Result
) {
21 const auto *S
= Result
.Nodes
.getNodeAs
<CXXDefaultArgExpr
>("stmt");
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",
31 } // namespace clang::tidy::fuchsia