[PATCH] D15844: [ADT] Add an abstraction for embedding an integer within a pointer-like type.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 2 02:51:14 PST 2016
chandlerc created this revision.
chandlerc added a reviewer: rsmith.
chandlerc added a subscriber: llvm-commits.
This makes it easy and safe to use a set of flags as one elmenet of
a tagged union with pointers. There is quite a bit of code that has
historically done this by casting arbitrary integers to "pointers" and
assuming that this was safe and reliable. It is neither, and has started
to rear its head by triggering safety asserts in various abstractions
like PointerLikeTypeTraits when the integers chosen are invariably poor
choices for *some* platform and *some* situation. Not to mention the
(hopefully unlikely) prospect of one of these integers actually getting
With this, it will be straightforward to build type safe abstractions
like this without being error prone. The abstraction itself is also
remarkably simple thanks to the implicit conversion.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5677 bytes
Desc: not available
More information about the llvm-commits