mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
f69ee08c94
Summary: D44883 extends -Wself-assign to also work on C++ classes. In it's current state (as suggested by @rjmccall), it is not under it's own sub-group. Since that diag is enabled by `-Wall`, stage2 testing showed that: * It does not fire on any llvm code * It does fire for these 3 unittests * It does fire for libc++ tests This diff simply silences those new warnings in llvm's unittests. A similar diff will be needed for libcxx. (`libcxx/test/std/language.support/support.types/byteops/`, maybe something else) Since i don't think we want to repeat rL322901, let's talk about it. I've subscribed everyone who i think might be interested... There are several ways forward: * Not extend -Wself-assign, close D44883. Not very productive outcome i'd say. * Keep D44883 in it's current state. Unless your custom overloaded operators do something unusual for when self-assigning, the warning is no less of a false-positive than the current -Wself-assign. Except for tests of course, there you'd want to silence it. The current suggestion is: ``` S a; a = (S &)a; ``` * Split the diagnostic in two - `-Wself-assign-builtin` (i.e. what is `-Wself-assign` in trunk), and `-Wself-assign-overloaded` - the new part in D44883. Since, as i said, i'm not really sure why it would be less of a error than the current `-Wself-assign`, both would still be in `-Wall`. That way one could simply pass `-Wno-self-assign-overloaded` for all the tests. Pretty simple to do, and will surely work. * Split the diagnostic in two - `-Wself-assign-trivial`, and `-Wself-assign-nontrivial`. The choice of which diag to emit would depend on trivial-ness of that particular operator. The current `-Wself-assign` would be `-Wself-assign-trivial`. https://godbolt.org/g/gwDASe - `A`, `B` and `C` case would be treated as trivial, and `D`, `E` and `F` as non-trivial. Will be the most complicated to implement. Thoughts? Reviewers: aaron.ballman, rsmith, rtrieu, rjmccall, dblaikie, atrick, gottesmm Reviewed By: dblaikie Subscribers: lebedev.ri, phosek, vsk, rnk, thakis, sammccall, mclow.lists, llvm-commits, rjmccall Differential Revision: https://reviews.llvm.org/D45082 llvm-svn: 329491
170 lines
3.5 KiB
C++
170 lines
3.5 KiB
C++
//===- llvm/unittest/ADT/SparseBitVectorTest.cpp - SparseBitVector tests --===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ADT/SparseBitVector.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
TEST(SparseBitVectorTest, TrivialOperation) {
|
|
SparseBitVector<> Vec;
|
|
EXPECT_EQ(0U, Vec.count());
|
|
EXPECT_FALSE(Vec.test(17));
|
|
Vec.set(5);
|
|
EXPECT_TRUE(Vec.test(5));
|
|
EXPECT_FALSE(Vec.test(17));
|
|
Vec.reset(6);
|
|
EXPECT_TRUE(Vec.test(5));
|
|
EXPECT_FALSE(Vec.test(6));
|
|
Vec.reset(5);
|
|
EXPECT_FALSE(Vec.test(5));
|
|
EXPECT_TRUE(Vec.test_and_set(17));
|
|
EXPECT_FALSE(Vec.test_and_set(17));
|
|
EXPECT_TRUE(Vec.test(17));
|
|
Vec.clear();
|
|
EXPECT_FALSE(Vec.test(17));
|
|
}
|
|
|
|
TEST(SparseBitVectorTest, IntersectWith) {
|
|
SparseBitVector<> Vec, Other;
|
|
|
|
Vec.set(1);
|
|
Other.set(1);
|
|
EXPECT_FALSE(Vec &= Other);
|
|
EXPECT_TRUE(Vec.test(1));
|
|
|
|
Vec.clear();
|
|
Vec.set(5);
|
|
Other.clear();
|
|
Other.set(6);
|
|
EXPECT_TRUE(Vec &= Other);
|
|
EXPECT_TRUE(Vec.empty());
|
|
|
|
Vec.clear();
|
|
Vec.set(5);
|
|
Other.clear();
|
|
Other.set(225);
|
|
EXPECT_TRUE(Vec &= Other);
|
|
EXPECT_TRUE(Vec.empty());
|
|
|
|
Vec.clear();
|
|
Vec.set(225);
|
|
Other.clear();
|
|
Other.set(5);
|
|
EXPECT_TRUE(Vec &= Other);
|
|
EXPECT_TRUE(Vec.empty());
|
|
}
|
|
|
|
TEST(SparseBitVectorTest, SelfAssignment) {
|
|
SparseBitVector<> Vec, Other;
|
|
|
|
Vec.set(23);
|
|
Vec.set(234);
|
|
Vec = static_cast<SparseBitVector<> &>(Vec);
|
|
EXPECT_TRUE(Vec.test(23));
|
|
EXPECT_TRUE(Vec.test(234));
|
|
|
|
Vec.clear();
|
|
Vec.set(17);
|
|
Vec.set(256);
|
|
EXPECT_FALSE(Vec |= Vec);
|
|
EXPECT_TRUE(Vec.test(17));
|
|
EXPECT_TRUE(Vec.test(256));
|
|
|
|
Vec.clear();
|
|
Vec.set(56);
|
|
Vec.set(517);
|
|
EXPECT_FALSE(Vec &= Vec);
|
|
EXPECT_TRUE(Vec.test(56));
|
|
EXPECT_TRUE(Vec.test(517));
|
|
|
|
Vec.clear();
|
|
Vec.set(99);
|
|
Vec.set(333);
|
|
EXPECT_TRUE(Vec.intersectWithComplement(Vec));
|
|
EXPECT_TRUE(Vec.empty());
|
|
EXPECT_FALSE(Vec.intersectWithComplement(Vec));
|
|
|
|
Vec.clear();
|
|
Vec.set(28);
|
|
Vec.set(43);
|
|
Vec.intersectWithComplement(Vec, Vec);
|
|
EXPECT_TRUE(Vec.empty());
|
|
|
|
Vec.clear();
|
|
Vec.set(42);
|
|
Vec.set(567);
|
|
Other.set(55);
|
|
Other.set(567);
|
|
Vec.intersectWithComplement(Vec, Other);
|
|
EXPECT_TRUE(Vec.test(42));
|
|
EXPECT_FALSE(Vec.test(567));
|
|
|
|
Vec.clear();
|
|
Vec.set(19);
|
|
Vec.set(21);
|
|
Other.clear();
|
|
Other.set(19);
|
|
Other.set(31);
|
|
Vec.intersectWithComplement(Other, Vec);
|
|
EXPECT_FALSE(Vec.test(19));
|
|
EXPECT_TRUE(Vec.test(31));
|
|
|
|
Vec.clear();
|
|
Vec.set(1);
|
|
Other.clear();
|
|
Other.set(59);
|
|
Other.set(75);
|
|
Vec.intersectWithComplement(Other, Other);
|
|
EXPECT_TRUE(Vec.empty());
|
|
}
|
|
|
|
TEST(SparseBitVectorTest, Find) {
|
|
SparseBitVector<> Vec;
|
|
Vec.set(1);
|
|
EXPECT_EQ(1, Vec.find_first());
|
|
EXPECT_EQ(1, Vec.find_last());
|
|
|
|
Vec.set(2);
|
|
EXPECT_EQ(1, Vec.find_first());
|
|
EXPECT_EQ(2, Vec.find_last());
|
|
|
|
Vec.set(0);
|
|
Vec.set(3);
|
|
EXPECT_EQ(0, Vec.find_first());
|
|
EXPECT_EQ(3, Vec.find_last());
|
|
|
|
Vec.reset(1);
|
|
Vec.reset(0);
|
|
Vec.reset(3);
|
|
EXPECT_EQ(2, Vec.find_first());
|
|
EXPECT_EQ(2, Vec.find_last());
|
|
|
|
// Set some large bits to ensure we are pulling bits from more than just a
|
|
// single bitword.
|
|
Vec.set(500);
|
|
Vec.set(2000);
|
|
Vec.set(3000);
|
|
Vec.set(4000);
|
|
Vec.reset(2);
|
|
EXPECT_EQ(500, Vec.find_first());
|
|
EXPECT_EQ(4000, Vec.find_last());
|
|
|
|
Vec.reset(500);
|
|
Vec.reset(3000);
|
|
Vec.reset(4000);
|
|
EXPECT_EQ(2000, Vec.find_first());
|
|
EXPECT_EQ(2000, Vec.find_last());
|
|
|
|
Vec.clear();
|
|
}
|
|
}
|