[llvm] r208360 - StringMap: Replace faux-copyability with faux-movability, which is sufficient.

David Blaikie dblaikie at gmail.com
Thu May 8 14:52:26 PDT 2014


Author: dblaikie
Date: Thu May  8 16:52:26 2014
New Revision: 208360

URL: http://llvm.org/viewvc/llvm-project?rev=208360&view=rev
Log:
StringMap: Replace faux-copyability with faux-movability, which is sufficient.

This behavior was added to support StringMaps of StringMaps, default +
move construction are sufficient for this.

Real move construction support coming soon (& probably copy construction
too).

Modified:
    llvm/trunk/include/llvm/ADT/StringMap.h

Modified: llvm/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=208360&r1=208359&r2=208360&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Thu May  8 16:52:26 2014
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include <cstring>
+#include <utility>
 
 namespace llvm {
   template<typename ValueT>
@@ -48,13 +49,11 @@ protected:
   unsigned NumTombstones;
   unsigned ItemSize;
 protected:
-  explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {
-    // Initialize the map with zero buckets to allocation.
-    TheTable = nullptr;
-    NumBuckets = 0;
-    NumItems = 0;
-    NumTombstones = 0;
-  }
+  explicit StringMapImpl(unsigned itemSize)
+      : TheTable(nullptr),
+        // Initialize the map with zero buckets to allocation.
+        NumBuckets(0), NumItems(0), NumTombstones(0), ItemSize(itemSize) {}
+
   StringMapImpl(unsigned InitSize, unsigned ItemSize);
   void RehashTable();
 
@@ -233,18 +232,17 @@ public:
     : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
       Allocator(A) {}
 
-  StringMap(const StringMap &RHS)
-    : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {
-    assert(RHS.empty() &&
-           "Copy ctor from non-empty stringmap not implemented yet!");
-    (void)RHS;
-  }
-  void operator=(const StringMap &RHS) {
-    assert(RHS.empty() &&
-           "assignment from non-empty stringmap not implemented yet!");
-    (void)RHS;
+  StringMap(StringMap &&RHS)
+      : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {
+    assert(RHS.empty());
+  }
+  StringMap &operator=(StringMap &&RHS) {
+    assert(RHS.empty());
     clear();
+    return *this;
   }
+  StringMap(const StringMap &RHS) LLVM_DELETED_FUNCTION;
+  void operator=(const StringMap &RHS) LLVM_DELETED_FUNCTION;
 
   AllocatorTy &getAllocator() { return Allocator; }
   const AllocatorTy &getAllocator() const { return Allocator; }





More information about the llvm-commits mailing list