[PATCH] D15843: [ADT] Add a sum type abstraction for pointer-like types.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 2 02:49:29 PST 2016
chandlerc created this revision.
chandlerc added a reviewer: rsmith.
chandlerc added a subscriber: llvm-commits.
This is a much more general and powerful form of PointerUnion. It
provides a reasonably complete sum type (from type theory) for
pointer-like types. It has several significant advantages over the
existing PointerUnion infrastructure:
1) It allows more than two pointer types to participate without awkward
nesting structures.
2) It directly exposes the tag so that it is convenient to write
switches over the possible members.
3) It can re-use the same type for multiple tag values, something that
has been worked around by either abusing PointerIntPair or defining
nonce types and doing unsafe pointer casting.
4) It supports customization of the PointerLikeTypeTraits used for
specific member types. This means it could (in theory) be used even
with types that are over-aligned on allocation to expose larger
numbers of bits to the tag.
All in all, I think it is at least complimentary to the existing
infrastructure, and a strict improvement for some use cases.
http://reviews.llvm.org/D15843
Files:
include/llvm/ADT/PointerSumType.h
unittests/ADT/CMakeLists.txt
unittests/ADT/PointerSumTypeTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15843.43844.patch
Type: text/x-patch
Size: 12298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160102/309b6f13/attachment.bin>
More information about the llvm-commits
mailing list