[PATCH] D25647: [clang-tidy] Don't use a SmallSetVector of an enum.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 21 13:22:58 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL284873: [clang-tidy] Don't use a SmallSetVector of an enum. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25647?vs=75443&id=75478#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25647

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
===================================================================
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ clang-tools-extra/trunk/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,7 +43,7 @@
 
   using ClassDefiningSpecialMembersMap =
       llvm::DenseMap<ClassDefId,
-                     llvm::SmallSetVector<SpecialMemberFunctionKind, 5>>;
+                     llvm::SmallVector<SpecialMemberFunctionKind, 5>>;
 
 private:
   ClassDefiningSpecialMembersMap ClassWithSpecialMembers;
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -97,8 +97,13 @@
                   {"move-assign", SpecialMemberFunctionKind::MoveAssignment}};
 
   for (const auto &KV : Matchers)
-    if (Result.Nodes.getNodeAs<CXXMethodDecl>(KV.first))
-      ClassWithSpecialMembers[ID].insert(KV.second);
+    if (Result.Nodes.getNodeAs<CXXMethodDecl>(KV.first)) {
+      SpecialMemberFunctionKind Kind = KV.second;
+      llvm::SmallVectorImpl<SpecialMemberFunctionKind> &Members =
+          ClassWithSpecialMembers[ID];
+      if (find(Members, Kind) == Members.end())
+        Members.push_back(Kind);
+    }
 }
 
 void SpecialMemberFunctionsCheck::onEndOfTranslationUnit() {
@@ -125,7 +130,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 ");
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25647.75478.patch
Type: text/x-patch
Size: 2275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161021/ddf55fbe/attachment.bin>


More information about the cfe-commits mailing list