[PATCH] D45082: [RFC][unittests] ADT: silence -Wself-assign diagnostics

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 3 08:38:38 PDT 2018


lebedev.ri updated this revision to Diff 140805.
lebedev.ri added a comment.

And back to using cast instead of `*&`.


Repository:
  rL LLVM

https://reviews.llvm.org/D45082

Files:
  unittests/ADT/DenseMapTest.cpp
  unittests/ADT/SmallPtrSetTest.cpp
  unittests/ADT/SparseBitVectorTest.cpp


Index: unittests/ADT/SparseBitVectorTest.cpp
===================================================================
--- unittests/ADT/SparseBitVectorTest.cpp
+++ unittests/ADT/SparseBitVectorTest.cpp
@@ -68,7 +68,7 @@
 
   Vec.set(23);
   Vec.set(234);
-  Vec = Vec;
+  Vec = (SparseBitVector<> &)Vec;
   EXPECT_TRUE(Vec.test(23));
   EXPECT_TRUE(Vec.test(234));
 
Index: unittests/ADT/SmallPtrSetTest.cpp
===================================================================
--- unittests/ADT/SmallPtrSetTest.cpp
+++ unittests/ADT/SmallPtrSetTest.cpp
@@ -28,7 +28,7 @@
   (s2 = s1).insert(&buf[2]);
 
   // Self assign as well.
-  (s2 = s2).insert(&buf[3]);
+  (s2 = (SmallPtrSet<int *, 4> &)s2).insert(&buf[3]);
 
   s1 = s2;
   EXPECT_EQ(4U, s1.size());
@@ -56,7 +56,7 @@
 
   SmallPtrSet<int *, 4> s;
   typedef SmallPtrSet<int *, 4>::iterator iter;
-  
+
   s.insert(&buf[0]);
   s.insert(&buf[1]);
   s.insert(&buf[2]);
Index: unittests/ADT/DenseMapTest.cpp
===================================================================
--- unittests/ADT/DenseMapTest.cpp
+++ unittests/ADT/DenseMapTest.cpp
@@ -247,7 +247,7 @@
   EXPECT_EQ(this->getValue(), copyMap[this->getKey()]);
 
   // test self-assignment.
-  copyMap = copyMap;
+  copyMap = (TypeParam &)copyMap;
   EXPECT_EQ(1u, copyMap.size());
   EXPECT_EQ(this->getValue(), copyMap[this->getKey()]);
 }
@@ -262,7 +262,7 @@
     EXPECT_EQ(this->getValue(Key), copyMap[this->getKey(Key)]);
 
   // test self-assignment.
-  copyMap = copyMap;
+  copyMap = (TypeParam &)copyMap;
   EXPECT_EQ(5u, copyMap.size());
   for (int Key = 0; Key < 5; ++Key)
     EXPECT_EQ(this->getValue(Key), copyMap[this->getKey(Key)]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45082.140805.patch
Type: text/x-patch
Size: 1663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180403/0d50c818/attachment.bin>


More information about the llvm-commits mailing list