mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-18 06:38:41 +00:00
[ADT] Teach PointerUnion to support assignment directly from nullptr to
clear it out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207471 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b86c32fe38
commit
4ef6c0908b
@ -155,6 +155,12 @@ namespace llvm {
|
|||||||
return (PT1 *)Val.getAddrOfPointer();
|
return (PT1 *)Val.getAddrOfPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Assignment from nullptr which just clears the union.
|
||||||
|
const PointerUnion &operator=(std::nullptr_t) {
|
||||||
|
Val.initWithPointer(nullptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// Assignment operators - Allow assigning into this union from either
|
/// Assignment operators - Allow assigning into this union from either
|
||||||
/// pointer type, setting the discriminator to remember what it came from.
|
/// pointer type, setting the discriminator to remember what it came from.
|
||||||
const PointerUnion &operator=(const PT1 &RHS) {
|
const PointerUnion &operator=(const PT1 &RHS) {
|
||||||
@ -299,6 +305,12 @@ namespace llvm {
|
|||||||
return T();
|
return T();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Assignment from nullptr which just clears the union.
|
||||||
|
const PointerUnion3 &operator=(std::nullptr_t) {
|
||||||
|
Val = nullptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// Assignment operators - Allow assigning into this union from either
|
/// Assignment operators - Allow assigning into this union from either
|
||||||
/// pointer type, setting the discriminator to remember what it came from.
|
/// pointer type, setting the discriminator to remember what it came from.
|
||||||
const PointerUnion3 &operator=(const PT1 &RHS) {
|
const PointerUnion3 &operator=(const PT1 &RHS) {
|
||||||
@ -408,6 +420,12 @@ namespace llvm {
|
|||||||
return T();
|
return T();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Assignment from nullptr which just clears the union.
|
||||||
|
const PointerUnion4 &operator=(std::nullptr_t) {
|
||||||
|
Val = nullptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// Assignment operators - Allow assigning into this union from either
|
/// Assignment operators - Allow assigning into this union from either
|
||||||
/// pointer type, setting the discriminator to remember what it came from.
|
/// pointer type, setting the discriminator to remember what it came from.
|
||||||
const PointerUnion4 &operator=(const PT1 &RHS) {
|
const PointerUnion4 &operator=(const PT1 &RHS) {
|
||||||
|
@ -46,6 +46,12 @@ TEST_F(PointerUnionTest, Null) {
|
|||||||
EXPECT_TRUE((bool)a);
|
EXPECT_TRUE((bool)a);
|
||||||
EXPECT_TRUE((bool)b);
|
EXPECT_TRUE((bool)b);
|
||||||
EXPECT_FALSE(n);
|
EXPECT_FALSE(n);
|
||||||
|
|
||||||
|
EXPECT_NE(n, b);
|
||||||
|
EXPECT_EQ(b, c);
|
||||||
|
b = nullptr;
|
||||||
|
EXPECT_EQ(n, b);
|
||||||
|
EXPECT_NE(b, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PointerUnionTest, Is) {
|
TEST_F(PointerUnionTest, Is) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user