Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h +++ clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h @@ -31,7 +31,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; void onEndOfTranslationUnit() override; - enum class SpecialMemberFunctionKind { + enum class SpecialMemberFunctionKind : uint8_t { Destructor, CopyConstructor, CopyAssignment, @@ -43,9 +43,9 @@ using ClassDefiningSpecialMembersMap = llvm::DenseMap>; + llvm::SmallVector>; -private: + private: ClassDefiningSpecialMembersMap ClassWithSpecialMembers; }; Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp +++ clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp @@ -97,8 +97,11 @@ {"move-assign", SpecialMemberFunctionKind::MoveAssignment}}; for (const auto &KV : Matchers) - if (Result.Nodes.getNodeAs(KV.first)) - ClassWithSpecialMembers[ID].insert(KV.second); + if (Result.Nodes.getNodeAs(KV.first)) { + SpecialMemberFunctionKind Kind = KV.second; + auto &Members = ClassWithSpecialMembers[ID]; + if (find(Members, Kind) == Members.end()) Members.push_back(Kind); + } } void SpecialMemberFunctionsCheck::onEndOfTranslationUnit() { @@ -125,7 +128,7 @@ std::back_inserter(UndefinedSpecialMembers)); diag(C.first.first, "class '%0' defines %1 but does not define %2") - << C.first.second << join(DefinedSpecialMembers.getArrayRef(), " and ") + << C.first.second << join(DefinedSpecialMembers, " and ") << join(UndefinedSpecialMembers, " or "); } }