[PATCH] D45082: [RFC][unittests] ADT: silence -Wself-assign diagnostics
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 31 09:12:25 PDT 2018
lebedev.ri updated this revision to Diff 140546.
lebedev.ri added a comment.
- Rebase
- Drop comments
- Silence the warning via "*&" contraption, not by casting to the reference.
The main question still stands, do we want to recommend everyone to use that in their codebases,
or double the amount of diag flags and provide a way to silence this specific diagnostic?
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 = *&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 = *&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 = *©Map;
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 = *©Map;
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.140546.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180331/a6f30151/attachment.bin>
More information about the llvm-commits
mailing list