10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
12#include "clang/Lex/Lexer.h"
26 auto PrivateSpecialFn = cxxMethodDecl(
28 anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(),
29 isCopyConstructor(), isMoveConstructor())),
31 anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())),
32 cxxDestructorDecl()));
37 unless(anyOf(hasAnyBody(stmt()), isDefaulted(), isDeleted(),
38 ast_matchers::isTemplateInstantiation(),
41 hasParent(cxxRecordDecl(hasMethod(unless(
42 anyOf(PrivateSpecialFn, hasAnyBody(stmt()), isPure(),
43 isDefaulted(), isDeleted()))))))))
53 if (
const auto *Func =
55 SourceLocation EndLoc = Lexer::getLocForEndOfToken(
56 Func->getEndLoc(), 0, *Result.SourceManager,
getLangOpts());
58 if (Func->getLocation().isMacroID() && IgnoreMacros)
61 diag(Func->getLocation(),
62 "use '= delete' to prohibit calling of a special member function")
63 << FixItHint::CreateInsertion(EndLoc,
" = delete");
64 }
else if (
const auto *Func =
69 if (Func->getLocation().isMacroID() && IgnoreMacros)
72 diag(Func->getLocation(),
"deleted member function should be public");
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.
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.
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.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
static const char DeletedNotPublic[]
static const char SpecialFunction[]
llvm::StringMap< ClangTidyValue > OptionMap