10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
12#include "clang/Lex/Lexer.h"
20 if (Node.hasBody() || Node.isPureVirtual() || Node.isDefaulted() ||
24 if (
const FunctionDecl *Definition = Node.getDefinition())
35 if (
const auto *Constructor = dyn_cast<CXXConstructorDecl>(&Node))
39 return isa<CXXDestructorDecl>(Node) || Node.isCopyAssignmentOperator() ||
40 Node.isMoveAssignmentOperator();
50 IgnoreMacros(Options.get(
"IgnoreMacros", true)) {}
53 Options.store(Opts,
"IgnoreMacros", IgnoreMacros);
57 auto PrivateSpecialFn = cxxMethodDecl(isPrivate(), isSpecialFunction());
61 PrivateSpecialFn, unless(hasAnyDefinition()), unless(isUsed()),
64 unless(ofClass(hasMethod(cxxMethodDecl(unless(PrivateSpecialFn),
65 unless(hasAnyDefinition()))))))
75 if (
const auto *Func =
77 const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
78 Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
80 if (IgnoreMacros && Func->getLocation().isMacroID())
83 diag(Func->getLocation(),
84 "use '= delete' to prohibit calling of a special member function")
85 << FixItHint::CreateInsertion(EndLoc,
" = delete");
86 }
else if (
const auto *Func =
91 if (IgnoreMacros && Func->getLocation().isMacroID())
94 diag(Func->getLocation(),
"deleted member function should be public");
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
AST_MATCHER(BinaryOperator, isRelationalOperator)
static constexpr char SpecialFunction[]
static constexpr char DeletedNotPublic[]
llvm::StringMap< ClangTidyValue > OptionMap