diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-29 00:14:27 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-29 00:14:27 +0000 |
commit | 4ef6c0908bbadea8b827aaaf0cb51e543bef5f3d (patch) | |
tree | 168410fb32a21f47f4a225183ad75cee8d872d19 /include/llvm | |
parent | b86c32fe3859989447d1b31fbf74b216d32c0405 (diff) | |
download | llvm-4ef6c0908bbadea8b827aaaf0cb51e543bef5f3d.tar.gz llvm-4ef6c0908bbadea8b827aaaf0cb51e543bef5f3d.tar.bz2 llvm-4ef6c0908bbadea8b827aaaf0cb51e543bef5f3d.tar.xz |
[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
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/ADT/PointerUnion.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index dafd0e0510..a6dddd2776 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -154,6 +154,12 @@ namespace llvm { "Can't get the address because PointerLikeTypeTraits changes the ptr"); 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 /// pointer type, setting the discriminator to remember what it came from. @@ -298,6 +304,12 @@ namespace llvm { if (is<T>()) return get<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 /// pointer type, setting the discriminator to remember what it came from. @@ -407,6 +419,12 @@ namespace llvm { if (is<T>()) return get<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 /// pointer type, setting the discriminator to remember what it came from. |