mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
fbbe67869c
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 |
||
---|---|---|
.. | ||
AlignOfTest.cpp | ||
AllocatorTest.cpp | ||
ARMAttributeParser.cpp | ||
ArrayRecyclerTest.cpp | ||
BinaryStreamTest.cpp | ||
BlockFrequencyTest.cpp | ||
BranchProbabilityTest.cpp | ||
CachePruningTest.cpp | ||
Casting.cpp | ||
Chrono.cpp | ||
CMakeLists.txt | ||
CommandLineTest.cpp | ||
CompressionTest.cpp | ||
ConvertUTFTest.cpp | ||
DataExtractorTest.cpp | ||
DebugTest.cpp | ||
DwarfTest.cpp | ||
EndianStreamTest.cpp | ||
EndianTest.cpp | ||
ErrorOrTest.cpp | ||
ErrorTest.cpp | ||
FileOutputBufferTest.cpp | ||
formatted_raw_ostream_test.cpp | ||
FormatVariadicTest.cpp | ||
GlobPatternTest.cpp | ||
Host.cpp | ||
LEB128Test.cpp | ||
LineIteratorTest.cpp | ||
LockFileManagerTest.cpp | ||
ManagedStatic.cpp | ||
MathExtrasTest.cpp | ||
MD5Test.cpp | ||
MemoryBufferTest.cpp | ||
MemoryTest.cpp | ||
NativeFormatTests.cpp | ||
Path.cpp | ||
ProcessTest.cpp | ||
ProgramTest.cpp | ||
raw_ostream_test.cpp | ||
raw_pwrite_stream_test.cpp | ||
raw_sha1_ostream_test.cpp | ||
RegexTest.cpp | ||
ReplaceFileTest.cpp | ||
ScaledNumberTest.cpp | ||
SourceMgrTest.cpp | ||
SpecialCaseListTest.cpp | ||
StringPool.cpp | ||
SwapByteOrderTest.cpp | ||
TargetParserTest.cpp | ||
TarWriterTest.cpp | ||
Threading.cpp | ||
ThreadLocalTest.cpp | ||
ThreadPool.cpp | ||
TimerTest.cpp | ||
TrailingObjectsTest.cpp | ||
TrigramIndexTest.cpp | ||
TypeNameTest.cpp | ||
UnicodeTest.cpp | ||
xxhashTest.cpp | ||
YAMLIOTest.cpp | ||
YAMLParserTest.cpp |