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.getLocalOrGlobal(
"IgnoreMacros", true)) {}
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 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");
const FunctionDecl * Decl
llvm::SmallString< 256U > Name
::clang::DynTypedNode Node
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
Base class for all clang-tidy checks.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
const LangOptions & getLangOpts() const
Returns the language options from the context.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
AST_MATCHER(Decl, declHasNoReturnAttr)
matches a Decl if it has a "no return" attribute of any kind
static const char DeletedNotPublic[]
static const char SpecialFunction[]
llvm::StringMap< ClangTidyValue > OptionMap