16AST_MATCHER(FunctionDecl, isFuchsiaOverloadedOperator) {
17 if (
const auto *CXXMethodNode = dyn_cast<CXXMethodDecl>(&Node)) {
18 if (CXXMethodNode->isCopyAssignmentOperator() ||
19 CXXMethodNode->isMoveAssignmentOperator())
21 if (CXXMethodNode->getParent()->isLambda())
24 return Node.isOverloadedOperator();
29 Finder->addMatcher(functionDecl(isFuchsiaOverloadedOperator()).bind(
"decl"),
34 const auto *D = Result.Nodes.getNodeAs<FunctionDecl>(
"decl");
35 assert(D &&
"No FunctionDecl captured!");
37 SourceLocation
Loc = D->getBeginLoc();
39 diag(
Loc,
"overloading %0 is disallowed") << D;
::clang::DynTypedNode Node
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
AST_MATCHER(Decl, declHasNoReturnAttr)
matches a Decl if it has a "no return" attribute of any kind