10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
12 #include "clang/ASTMatchers/ASTMatchers.h"
21 void OverloadedUnaryAndCheck::registerMatchers(
22 ast_matchers::MatchFinder *Finder) {
25 cxxMethodDecl(parameterCountIs(0), hasOverloadedOperatorName(
"&"))
30 Finder->addMatcher(functionDecl(unless(cxxMethodDecl()), parameterCountIs(1),
31 hasOverloadedOperatorName(
"&"))
37 const auto *
Decl = Result.Nodes.getNodeAs<FunctionDecl>(
"overload");
38 diag(
Decl->getBeginLoc(),
39 "do not overload unary operator&, it is dangerous.");