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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 6 14:07:10 PDT 2018


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

Don't use C-style cast, use `static_cast<>()`, as suggested by @dblaikie


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 = static_cast<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 = static_cast<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 = static_cast<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 = static_cast<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.141418.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180406/bde9ce73/attachment.bin>


More information about the llvm-commits mailing list