10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SPECIAL_MEMBER_FUNCTIONS_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SPECIAL_MEMBER_FUNCTIONS_H
13 #include "../ClangTidy.h"
15 #include "llvm/ADT/DenseMapInfo.h"
19 namespace cppcoreguidelines {
31 void check(
const ast_matchers::MatchFinder::MatchResult &
Result)
override;
42 using ClassDefId = std::pair<SourceLocation, std::string>;
46 llvm::SmallVector<SpecialMemberFunctionKind, 5>>;
62 clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId> {
68 clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-1)),
74 clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-2)),
79 assert(Val != getEmptyKey() &&
"Cannot hash the empty key!");
80 assert(Val != getTombstoneKey() &&
"Cannot hash the tombstone key!");
82 std::hash<ClassDefId::second_type> SecondHash;
83 return Val.first.getRawEncoding() + SecondHash(Val.second);
87 if (RHS == getEmptyKey())
88 return LHS == getEmptyKey();
89 if (RHS == getTombstoneKey())
90 return LHS == getTombstoneKey();
97 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SPECIAL_MEMBER_FUNCTIONS_H
void onEndOfTranslationUnit() override
Checks for classes where some, but not all, of the special member functions are defined.
SpecialMemberFunctionKind
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId ClassDefId
std::unique_ptr< ast_matchers::MatchFinder > Finder
static unsigned getHashValue(ClassDefId Val)
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.
Base class for all clang-tidy checks.
llvm::DenseMap< ClassDefId, llvm::SmallVector< SpecialMemberFunctionKind, 5 >> ClassDefiningSpecialMembersMap
static bool isEqual(ClassDefId LHS, ClassDefId RHS)
static ClassDefId getEmptyKey()
SpecialMemberFunctionsCheck(StringRef Name, ClangTidyContext *Context)
static ClassDefId getTombstoneKey()
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
std::pair< SourceLocation, std::string > ClassDefId