11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 13 #include "clang/ASTMatchers/ASTMatchers.h" 22 void OverloadedUnaryAndCheck::registerMatchers(
23 ast_matchers::MatchFinder *Finder) {
26 if (!getLangOpts().CPlusPlus)
31 cxxMethodDecl(parameterCountIs(0), hasOverloadedOperatorName(
"&"))
36 Finder->addMatcher(functionDecl(unless(cxxMethodDecl()), parameterCountIs(1),
37 hasOverloadedOperatorName(
"&"))
42 void OverloadedUnaryAndCheck::check(
const MatchFinder::MatchResult &
Result) {
43 const auto *Decl = Result.Nodes.getNodeAs<FunctionDecl>(
"overload");
44 diag(Decl->getBeginLoc(),
45 "do not overload unary operator&, it is dangerous.");
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//