1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/unittests
Zachary Turner fbbe67869c [Support] Add support for unique_ptr<> to Casting.h.
Often you have a unique_ptr<T> where T supports LLVM's
casting methods, and you wish to cast it to a unique_ptr<U>.
Prior to this patch, this requires doing hacky things like:

unique_ptr<U> Casted;
if (isa<U>(Orig.get()))
  Casted.reset(cast<U>(Orig.release()));

This is overly verbose, and it would be nice to just be able
to use unique_ptr directly with cast and dyn_cast.  To this end,
this patch updates cast<> to work directly with unique_ptr<T>,
so you can now write:

auto Casted = cast<U>(std::move(Orig));

Since it's possible for dyn_cast<> to fail, however, we choose
to use a slightly different API here, because it's awkward to
write

if (auto Casted = dyn_cast<U>(std::move(Orig))) {}

when Orig may end up not having been moved at all.  So the
interface for dyn_cast is

if (auto Casted = unique_dyn_cast<U>(Orig)) {}

Where the inclusion of `unique` in the name of the cast operator
re-affirms that regardless of success of or fail of the casting,
exactly one of the input value and the return value will contain
a non-null result.

Differential Revision: https://reviews.llvm.org/D31890

llvm-svn: 300098
2017-04-12 19:59:37 +00:00
..
ADT Fix signed / unsigned comparison warnings. 2017-04-10 20:01:50 +00:00
Analysis MemorySSA: Move to Analysis, from Transforms/Utils. It's used as 2017-04-11 20:06:36 +00:00
AsmParser Remove every uses of getGlobalContext() in LLVM (but the C API) 2016-04-14 21:59:01 +00:00
Bitcode Reapply "Make BitCodeAbbrev ownership explicit using shared_ptr rather than IntrusiveRefCntPtr"" 2017-01-04 22:36:33 +00:00
CodeGen Recommit: [globalisel] Change LLT constructor string into an LLT-based object that knows how to generate it. 2017-03-07 23:20:35 +00:00
DebugInfo Fix llvm-symbolizer to navigate both DW_AT_abstract_origin and DW_AT_specification in a single chain 2017-03-13 21:46:37 +00:00
ExecutionEngine [Orc] Add missing header include for r299611. 2017-04-06 04:12:47 +00:00
IR [IR] Redesign the case iterator in SwitchInst to actually be an iterator 2017-04-12 07:27:28 +00:00
LineEditor Remove autoconf support 2016-01-26 21:29:08 +00:00
Linker Implement intrinsic mangling for literal struct types. 2017-02-15 23:16:20 +00:00
MC Fix static initialization order fiasco in MCTests 2016-11-11 22:18:42 +00:00
MI Fix subreg value numbers in handleMoveUp 2017-03-11 00:14:52 +00:00
Object Fix unittest for buildbot with mips host (32bit big endian) from r295174 2017-02-15 16:03:22 +00:00
ObjectYAML Move ObjectYAML code to a new library. 2016-03-01 19:15:06 +00:00
Option Option parser: class for consuming a joined arg in addition to all remaining args 2016-04-15 00:23:30 +00:00
ProfileData Fix signed/unsigned comparison warning 2017-03-11 19:38:22 +00:00
Support [Support] Add support for unique_ptr<> to Casting.h. 2017-04-12 19:59:37 +00:00
Target Remove a FIXME that I forgot about. NFC. 2016-10-13 05:28:55 +00:00
Transforms MemorySSA: Move to Analysis, from Transforms/Utils. It's used as 2017-04-11 20:06:36 +00:00
XRay [XRay][graph] Disambiguate name of type from member name 2017-02-10 06:59:25 +00:00
CMakeLists.txt [XRay] A graph Class for the llvm-xray graph 2017-02-10 06:36:08 +00:00