llvm.org GIT mirror llvm / 50f8a53
Missed formatting git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208362 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 5 years ago
2 changed file(s) with 17 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
5252 : TheTable(nullptr),
5353 // Initialize the map with zero buckets to allocation.
5454 NumBuckets(0), NumItems(0), NumTombstones(0), ItemSize(itemSize) {}
55 StringMapImpl(StringMapImpl &&RHS) : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets), NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones), ItemSize(RHS.ItemSize) {
55 StringMapImpl(StringMapImpl &&RHS)
56 : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets),
57 NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones),
58 ItemSize(RHS.ItemSize) {
5659 RHS.TheTable = nullptr;
5760 RHS.NumBuckets = 0;
5861 RHS.NumItems = 0;
114117 explicit StringMapEntry(unsigned strLen)
115118 : StringMapEntryBase(strLen), second() {}
116119 StringMapEntry(unsigned strLen, ValueTy V)
117 : StringMapEntryBase(strLen), second(std::move(V)) {}
120 : StringMapEntryBase(strLen), second(std::move(V)) {}
118121
119122 StringRef getKey() const {
120123 return StringRef(getKeyData(), getKeyLength());
350353 return *static_cast(Bucket);
351354
352355 MapEntryTy *NewItem =
353 MapEntryTy::Create(Key.begin(), Key.end(), Allocator, std::move(Val));
356 MapEntryTy::Create(Key.begin(), Key.end(), Allocator, std::move(Val));
354357
355358 if (Bucket == getTombstoneVal())
356359 --NumTombstones;
220220 struct MoveOnly {
221221 int i;
222222 MoveOnly(int i) : i(i) {}
223 MoveOnly(MoveOnly&&) = default;
224 MoveOnly(const MoveOnly&) = delete;
225 MoveOnly &operator=(MoveOnly&&) = default;
226 MoveOnly &operator=(const MoveOnly&) = delete;
223 MoveOnly(MoveOnly &&) = default;
224 MoveOnly(const MoveOnly &) = delete;
225 MoveOnly &operator=(MoveOnly &&) = default;
226 MoveOnly &operator=(const MoveOnly &) = delete;
227227 };
228228
229229 TEST_F(StringMapTest, MoveOnlyKey) {
230230 StringMap t;
231231 t.GetOrCreateValue("Test", MoveOnly(42));
232232 StringRef Key = "Test";
233 StringMapEntry::Create(Key.begin(), Key.end(), MoveOnly(42))->Destroy();
233 StringMapEntry::Create(Key.begin(), Key.end(), MoveOnly(42))
234 ->Destroy();
234235 }
235236
236237 TEST_F(StringMapTest, MoveConstruct) {
258259 struct Countable {
259260 int &InstanceCount;
260261 int Number;
261 Countable(int Number, int &InstanceCount) :InstanceCount(InstanceCount), Number(Number) {
262 Countable(int Number, int &InstanceCount)
263 : InstanceCount(InstanceCount), Number(Number) {
262264 ++InstanceCount;
263265 }
264266 Countable(Countable &&C) : InstanceCount(C.InstanceCount), Number(C.Number) {
265267 ++InstanceCount;
266268 C.Number = -1;
267269 }
268 Countable(const Countable &C) : InstanceCount(C.InstanceCount), Number(C.Number) {
270 Countable(const Countable &C)
271 : InstanceCount(C.InstanceCount), Number(C.Number) {
269272 ++InstanceCount;
270273 }
271274 Countable &operator=(Countable C) {
272275 Number = C.Number;
273276 return *this;
274277 }
275 ~Countable() {
276 --InstanceCount;
277 }
278
278 ~Countable() { --InstanceCount; }
279279 };
280280
281281 TEST_F(StringMapTest, MoveDtor) {