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 if (!getLangOpts().CPlusPlus)
30 cxxMethodDecl(parameterCountIs(0), hasOverloadedOperatorName(
"&"))
35 Finder->addMatcher(functionDecl(unless(cxxMethodDecl()), parameterCountIs(1),
36 hasOverloadedOperatorName(
"&"))
41 void OverloadedUnaryAndCheck::check(
const MatchFinder::MatchResult &Result) {
42 const auto *
Decl = Result.Nodes.getNodeAs<FunctionDecl>(
"overload");
43 diag(
Decl->getBeginLoc(),
44 "do not overload unary operator&, it is dangerous.");
const FunctionDecl * Decl
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//