From 19e7ab14ac4ab3e3204632e851034cc845927271 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 1 Aug 2014 14:31:55 +0000 Subject: [PATCH] Remove some calls to std::move. Instead of moving out the data in a ErrorOr>, get a reference to it. Thanks to David Blaikie for the suggestion. llvm-svn: 214516 --- lib/ExecutionEngine/MCJIT/MCJIT.cpp | 2 +- lib/Support/CommandLine.cpp | 6 ++-- lib/Support/FileUtilities.cpp | 16 +++++------ lib/Support/LockFileManager.cpp | 4 +-- lib/Transforms/Scalar/SampleProfile.cpp | 4 +-- tools/llvm-ar/llvm-ar.cpp | 9 +++--- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 8 +++--- tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 6 ++-- tools/llvm-nm/llvm-nm.cpp | 28 +++++++++---------- tools/llvm-objdump/llvm-objdump.cpp | 6 ++-- tools/llvm-readobj/llvm-readobj.cpp | 6 ++-- tools/llvm-size/llvm-size.cpp | 8 +++--- tools/llvm-symbolizer/LLVMSymbolize.cpp | 2 +- tools/llvm-vtabledump/llvm-vtabledump.cpp | 6 ++-- tools/macho-dump/macho-dump.cpp | 4 +-- tools/obj2yaml/obj2yaml.cpp | 4 +-- .../verify-uselistorder.cpp | 4 +-- utils/FileCheck/FileCheck.cpp | 2 +- utils/yaml-bench/YAMLBench.cpp | 6 ++-- 19 files changed, 65 insertions(+), 66 deletions(-) diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 5025aa61278..a86f85c9f4c 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -307,7 +307,7 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name, ChildIt->getAsBinary(); if (ChildBinOrErr.getError()) continue; - std::unique_ptr ChildBin = std::move(ChildBinOrErr.get()); + std::unique_ptr &ChildBin = ChildBinOrErr.get(); if (ChildBin->isObject()) { std::unique_ptr OF( static_cast(ChildBin.release())); diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 586eceae757..4c1df5c47dd 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -635,11 +635,11 @@ static bool ExpandResponseFile(const char *FName, StringSaver &Saver, MemoryBuffer::getFile(FName); if (!MemBufOrErr) return false; - std::unique_ptr MemBuf = std::move(MemBufOrErr.get()); - StringRef Str(MemBuf->getBufferStart(), MemBuf->getBufferSize()); + MemoryBuffer &MemBuf = *MemBufOrErr.get(); + StringRef Str(MemBuf.getBufferStart(), MemBuf.getBufferSize()); // If we have a UTF-16 byte order mark, convert to UTF-8 for parsing. - ArrayRef BufRef(MemBuf->getBufferStart(), MemBuf->getBufferEnd()); + ArrayRef BufRef(MemBuf.getBufferStart(), MemBuf.getBufferEnd()); std::string UTF8Buf; if (hasUTF16ByteOrderMark(BufRef)) { if (!convertUTF16ToUTF8String(BufRef, UTF8Buf)) diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 8a234917827..5316f049a38 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -182,7 +182,7 @@ int llvm::DiffFilesWithTolerance(StringRef NameA, *Error = EC.message(); return 2; } - std::unique_ptr F1 = std::move(F1OrErr.get()); + MemoryBuffer &F1 = *F1OrErr.get(); ErrorOr> F2OrErr = MemoryBuffer::getFile(NameB); if (std::error_code EC = F2OrErr.getError()) { @@ -190,17 +190,17 @@ int llvm::DiffFilesWithTolerance(StringRef NameA, *Error = EC.message(); return 2; } - std::unique_ptr F2 = std::move(F2OrErr.get()); + MemoryBuffer &F2 = *F2OrErr.get(); // Okay, now that we opened the files, scan them for the first difference. - const char *File1Start = F1->getBufferStart(); - const char *File2Start = F2->getBufferStart(); - const char *File1End = F1->getBufferEnd(); - const char *File2End = F2->getBufferEnd(); + const char *File1Start = F1.getBufferStart(); + const char *File2Start = F2.getBufferStart(); + const char *File1End = F1.getBufferEnd(); + const char *File2End = F2.getBufferEnd(); const char *F1P = File1Start; const char *F2P = File2Start; - uint64_t A_size = F1->getBufferSize(); - uint64_t B_size = F2->getBufferSize(); + uint64_t A_size = F1.getBufferSize(); + uint64_t B_size = F2.getBufferSize(); // Are the buffers identical? Common case: Handle this efficiently. if (A_size == B_size && diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp index 3f224e0c588..8fc58017cb0 100644 --- a/lib/Support/LockFileManager.cpp +++ b/lib/Support/LockFileManager.cpp @@ -39,11 +39,11 @@ LockFileManager::readLockFile(StringRef LockFileName) { sys::fs::remove(LockFileName); return None; } - std::unique_ptr MB = std::move(MBOrErr.get()); + MemoryBuffer &MB = *MBOrErr.get(); StringRef Hostname; StringRef PIDStr; - std::tie(Hostname, PIDStr) = getToken(MB->getBuffer(), " "); + std::tie(Hostname, PIDStr) = getToken(MB.getBuffer(), " "); PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" ")); int PID; if (!PIDStr.getAsInteger(10, PID)) { diff --git a/lib/Transforms/Scalar/SampleProfile.cpp b/lib/Transforms/Scalar/SampleProfile.cpp index 73c97ffeef4..56c57373a76 100644 --- a/lib/Transforms/Scalar/SampleProfile.cpp +++ b/lib/Transforms/Scalar/SampleProfile.cpp @@ -457,8 +457,8 @@ bool SampleModuleProfile::loadText() { M.getContext().diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg)); return false; } - std::unique_ptr Buffer = std::move(BufferOrErr.get()); - line_iterator LineIt(*Buffer, '#'); + MemoryBuffer &Buffer = *BufferOrErr.get(); + line_iterator LineIt(Buffer, '#'); // Read the profile of each function. Since each function may be // mentioned more than once, and we are collecting flat profiles, diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 3d5482df9de..3d87597f39b 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -703,7 +703,7 @@ writeSymbolTable(raw_fd_ostream &Out, ArrayRef Members, MemberBuffer, sys::fs::file_magic::unknown, &Context); if (!ObjOrErr) continue; // FIXME: check only for "not an object file" errors. - std::unique_ptr Obj = std::move(ObjOrErr.get()); + object::SymbolicFile &Obj = *ObjOrErr.get(); if (!StartOffset) { printMemberHeader(Out, "", sys::TimeValue::now(), 0, 0, 0, 0); @@ -711,7 +711,7 @@ writeSymbolTable(raw_fd_ostream &Out, ArrayRef Members, print32BE(Out, 0); } - for (const object::BasicSymbolRef &S : Obj->symbols()) { + for (const object::BasicSymbolRef &S : Obj.symbols()) { uint32_t Symflags = S.getFlags(); if (Symflags & object::SymbolRef::SF_FormatSpecific) continue; @@ -725,7 +725,7 @@ writeSymbolTable(raw_fd_ostream &Out, ArrayRef Members, MemberOffsetRefs.push_back(std::make_pair(Out.tell(), MemberNum)); print32BE(Out, 0); } - MemberBuffer.reset(Obj->releaseBuffer()); + MemberBuffer.reset(Obj.releaseBuffer()); } Out << NameOS.str(); @@ -763,7 +763,7 @@ static void performWriteOperation(ArchiveOperation Operation, MemberBuffers.resize(NewMembers.size()); for (unsigned I = 0, N = NewMembers.size(); I < N; ++I) { - std::unique_ptr MemberBuffer; + std::unique_ptr &MemberBuffer = MemberBuffers[I]; NewArchiveIterator &Member = NewMembers[I]; if (Member.isNewMember()) { @@ -781,7 +781,6 @@ static void performWriteOperation(ArchiveOperation Operation, failIfError(MemberBufferOrErr.getError()); MemberBuffer = std::move(MemberBufferOrErr.get()); } - MemberBuffers[I].reset(MemberBuffer.release()); } if (Symtab) { diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 63145c087a6..24ebbc1cb80 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -483,13 +483,13 @@ static int AnalyzeBitcode() { MemoryBuffer::getFileOrSTDIN(InputFilename); if (std::error_code EC = MemBufOrErr.getError()) return Error("Error reading '" + InputFilename + "': " + EC.message()); - std::unique_ptr MemBuf = std::move(MemBufOrErr.get()); + MemoryBuffer &MemBuf = *MemBufOrErr.get(); - if (MemBuf->getBufferSize() & 3) + if (MemBuf.getBufferSize() & 3) return Error("Bitcode stream should be a multiple of 4 bytes in length"); - const unsigned char *BufPtr = (const unsigned char *)MemBuf->getBufferStart(); - const unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); + const unsigned char *BufPtr = (const unsigned char *)MemBuf.getBufferStart(); + const unsigned char *EndBufPtr = BufPtr+MemBuf.getBufferSize(); // If we have a wrapper header, parse it and ignore the non-bc file contents. // The magic number is 0x0B17C0DE stored in little endian. diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 33bb766f200..4e65d444fc8 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -80,12 +80,12 @@ static void DumpInput(const StringRef &Filename) { errs() << Filename << ": " << EC.message() << '\n'; return; } - std::unique_ptr Obj = std::move(ObjOrErr.get()); + ObjectFile &Obj = *ObjOrErr.get(); - std::unique_ptr DICtx(DIContext::getDWARFContext(*Obj)); + std::unique_ptr DICtx(DIContext::getDWARFContext(Obj)); outs() << Filename - << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; + << ":\tfile format " << Obj.getFileFormatName() << "\n\n"; // Dump the complete DWARF structure. DICtx->dump(outs(), DumpType); } diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index a16135e0c7f..d7014264086 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -1013,9 +1013,9 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { createBinary(std::move(*BufferOrErr), &Context); if (error(BinaryOrErr.getError(), Filename)) return; - std::unique_ptr Bin = std::move(BinaryOrErr.get()); + Binary &Bin = *BinaryOrErr.get(); - if (Archive *A = dyn_cast(Bin.get())) { + if (Archive *A = dyn_cast(&Bin)) { if (ArchiveMap) { Archive::symbol_iterator I = A->symbol_begin(); Archive::symbol_iterator E = A->symbol_end(); @@ -1056,7 +1056,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } return; } - if (MachOUniversalBinary *UB = dyn_cast(Bin.get())) { + if (MachOUniversalBinary *UB = dyn_cast(&Bin)) { // If we have a list of architecture flags specified dump only those. if (!ArchAll && ArchFlags.size() != 0) { // Look for a slice in the universal binary that matches each ArchFlag. @@ -1076,16 +1076,16 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { ArchiveName.clear(); ArchitectureName.clear(); if (ObjOrErr) { - std::unique_ptr Obj = std::move(ObjOrErr.get()); + ObjectFile &Obj = *ObjOrErr.get(); if (ArchFlags.size() > 1) { if (PrintFileName) ArchitectureName = I->getArchTypeName(); else - outs() << "\n" << Obj->getFileName() << " (for architecture " + outs() << "\n" << Obj.getFileName() << " (for architecture " << I->getArchTypeName() << ")" << ":\n"; } - dumpSymbolNamesFromObject(*Obj, false, ArchiveName, + dumpSymbolNamesFromObject(Obj, false, ArchiveName, ArchitectureName); } else if (!I->getAsArchive(A)) { for (Archive::child_iterator AI = A->child_begin(), @@ -1138,8 +1138,8 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { std::string ArchiveName; ArchiveName.clear(); if (ObjOrErr) { - std::unique_ptr Obj = std::move(ObjOrErr.get()); - dumpSymbolNamesFromObject(*Obj, false); + ObjectFile &Obj = *ObjOrErr.get(); + dumpSymbolNamesFromObject(Obj, false); } else if (!I->getAsArchive(A)) { for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end(); @@ -1177,19 +1177,19 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { ArchiveName.clear(); ArchitectureName.clear(); if (ObjOrErr) { - std::unique_ptr Obj = std::move(ObjOrErr.get()); + ObjectFile &Obj = *ObjOrErr.get(); if (PrintFileName) { - if (isa(Obj.get()) && moreThanOneArch) + if (isa(Obj) && moreThanOneArch) ArchitectureName = I->getArchTypeName(); } else { if (moreThanOneArch) outs() << "\n"; - outs() << Obj->getFileName(); - if (isa(Obj.get()) && moreThanOneArch) + outs() << Obj.getFileName(); + if (isa(Obj) && moreThanOneArch) outs() << " (for architecture " << I->getArchTypeName() << ")"; outs() << ":\n"; } - dumpSymbolNamesFromObject(*Obj, false, ArchiveName, ArchitectureName); + dumpSymbolNamesFromObject(Obj, false, ArchiveName, ArchitectureName); } else if (!I->getAsArchive(A)) { for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end(); AI != AE; ++AI) { @@ -1220,7 +1220,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } return; } - if (SymbolicFile *O = dyn_cast(Bin.get())) { + if (SymbolicFile *O = dyn_cast(&Bin)) { if (!checkMachOAndArchFlags(O, Filename)) return; dumpSymbolNamesFromObject(*O, true); diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 8041a88396a..9e9526aa3cc 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -891,11 +891,11 @@ static void DumpInput(StringRef file) { errs() << ToolName << ": '" << file << "': " << EC.message() << ".\n"; return; } - std::unique_ptr binary = std::move(BinaryOrErr.get()); + Binary &Binary = *BinaryOrErr.get(); - if (Archive *a = dyn_cast(binary.get())) + if (Archive *a = dyn_cast(&Binary)) DumpArchive(a); - else if (ObjectFile *o = dyn_cast(binary.get())) + else if (ObjectFile *o = dyn_cast(&Binary)) DumpObject(o); else errs() << ToolName << ": '" << file << "': " << "Unrecognized file type.\n"; diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index 837b71f05dc..6e5b835f511 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -292,11 +292,11 @@ static void dumpInput(StringRef File) { reportError(File, EC); return; } - std::unique_ptr Binary = std::move(BinaryOrErr.get()); + Binary &Binary = *BinaryOrErr.get(); - if (Archive *Arc = dyn_cast(Binary.get())) + if (Archive *Arc = dyn_cast(&Binary)) dumpArchive(Arc); - else if (ObjectFile *Obj = dyn_cast(Binary.get())) + else if (ObjectFile *Obj = dyn_cast(&Binary)) dumpObject(Obj); else reportError(File, readobj_error::unrecognized_file_format); diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp index 0664d535b8b..24c9cd862fe 100644 --- a/tools/llvm-size/llvm-size.cpp +++ b/tools/llvm-size/llvm-size.cpp @@ -458,9 +458,9 @@ static void PrintFileSectionSizes(StringRef file) { errs() << ToolName << ": " << file << ": " << EC.message() << ".\n"; return; } - std::unique_ptr binary = std::move(BinaryOrErr.get()); + Binary &Bin = *BinaryOrErr.get(); - if (Archive *a = dyn_cast(binary.get())) { + if (Archive *a = dyn_cast(&Bin)) { // This is an archive. Iterate over each member and display its sizes. for (object::Archive::child_iterator i = a->child_begin(), e = a->child_end(); @@ -488,7 +488,7 @@ static void PrintFileSectionSizes(StringRef file) { } } } else if (MachOUniversalBinary *UB = - dyn_cast(binary.get())) { + dyn_cast(&Bin)) { // If we have a list of architecture flags specified dump only those. if (!ArchAll && ArchFlags.size() != 0) { // Look for a slice in the universal binary that matches each ArchFlag. @@ -692,7 +692,7 @@ static void PrintFileSectionSizes(StringRef file) { } } } - } else if (ObjectFile *o = dyn_cast(binary.get())) { + } else if (ObjectFile *o = dyn_cast(&Bin)) { if (!checkMachOAndArchFlags(o, file)) return; if (OutputFormat == sysv) diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index 7c4743b5dfb..14e193a5373 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -302,7 +302,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { Binary *DbgBin = nullptr; ErrorOr> BinaryOrErr = createBinary(Path); if (!error(BinaryOrErr.getError())) { - std::unique_ptr ParsedBinary = std::move(BinaryOrErr.get()); + std::unique_ptr &ParsedBinary = BinaryOrErr.get(); // Check if it's a universal binary. Bin = ParsedBinary.get(); ParsedBinariesAndObjects.push_back(std::move(ParsedBinary)); diff --git a/tools/llvm-vtabledump/llvm-vtabledump.cpp b/tools/llvm-vtabledump/llvm-vtabledump.cpp index d1d8aa4082b..2f6ccb0620a 100644 --- a/tools/llvm-vtabledump/llvm-vtabledump.cpp +++ b/tools/llvm-vtabledump/llvm-vtabledump.cpp @@ -169,11 +169,11 @@ static void dumpInput(StringRef File) { reportError(File, EC); return; } - std::unique_ptr Binary = std::move(BinaryOrErr.get()); + Binary &Binary = *BinaryOrErr.get(); - if (Archive *Arc = dyn_cast(Binary.get())) + if (Archive *Arc = dyn_cast(&Binary)) dumpArchive(Arc); - else if (ObjectFile *Obj = dyn_cast(Binary.get())) + else if (ObjectFile *Obj = dyn_cast(&Binary)) dumpVTables(Obj); else reportError(File, vtabledump_error::unrecognized_file_format); diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp index bbc7aae9f44..787aebc058d 100644 --- a/tools/macho-dump/macho-dump.cpp +++ b/tools/macho-dump/macho-dump.cpp @@ -406,9 +406,9 @@ int main(int argc, char **argv) { ErrorOr> BinaryOrErr = createBinary(InputFile); if (std::error_code EC = BinaryOrErr.getError()) return Error("unable to read input: '" + EC.message() + "'"); - std::unique_ptr Binary = std::move((BinaryOrErr.get())); + Binary &Binary = *BinaryOrErr.get(); - const MachOObjectFile *InputObject = dyn_cast(Binary.get()); + const MachOObjectFile *InputObject = dyn_cast(&Binary); if (!InputObject) return Error("Not a MachO object"); diff --git a/tools/obj2yaml/obj2yaml.cpp b/tools/obj2yaml/obj2yaml.cpp index 8d1c1409f18..dbf5a4acd16 100644 --- a/tools/obj2yaml/obj2yaml.cpp +++ b/tools/obj2yaml/obj2yaml.cpp @@ -36,9 +36,9 @@ static std::error_code dumpInput(StringRef File) { if (std::error_code EC = BinaryOrErr.getError()) return EC; - std::unique_ptr Binary = std::move(BinaryOrErr.get()); + Binary &Binary = *BinaryOrErr.get(); // TODO: If this is an archive, then burst it and dump each entry - if (ObjectFile *Obj = dyn_cast(Binary.get())) + if (ObjectFile *Obj = dyn_cast(&Binary)) return dumpObject(*Obj); return obj2yaml_error::unrecognized_file_format; diff --git a/tools/verify-uselistorder/verify-uselistorder.cpp b/tools/verify-uselistorder/verify-uselistorder.cpp index f5699e40c9b..a9666ac5284 100644 --- a/tools/verify-uselistorder/verify-uselistorder.cpp +++ b/tools/verify-uselistorder/verify-uselistorder.cpp @@ -153,8 +153,8 @@ std::unique_ptr TempFile::readBitcode(LLVMContext &Context) const { return nullptr; } - std::unique_ptr Buffer = std::move(BufferOr.get()); - ErrorOr ModuleOr = parseBitcodeFile(Buffer.get(), Context); + MemoryBuffer *Buffer = BufferOr.get().get(); + ErrorOr ModuleOr = parseBitcodeFile(Buffer, Context); if (!ModuleOr) { DEBUG(dbgs() << "error: " << ModuleOr.getError().message() << "\n"); return nullptr; diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 9cd1fe75760..8c62ae7f5d1 100644 --- a/utils/FileCheck/FileCheck.cpp +++ b/utils/FileCheck/FileCheck.cpp @@ -1258,7 +1258,7 @@ int main(int argc, char **argv) { << "': " << EC.message() << '\n'; return 2; } - std::unique_ptr File = std::move(FileOrErr.get()); + std::unique_ptr &File = FileOrErr.get(); if (File->getBufferSize() == 0) { errs() << "FileCheck error: '" << InputFilename << "' is empty.\n"; diff --git a/utils/yaml-bench/YAMLBench.cpp b/utils/yaml-bench/YAMLBench.cpp index e88ce5daeba..8bd1ea17ea8 100644 --- a/utils/yaml-bench/YAMLBench.cpp +++ b/utils/yaml-bench/YAMLBench.cpp @@ -192,15 +192,15 @@ int main(int argc, char **argv) { MemoryBuffer::getFileOrSTDIN(Input); if (!BufOrErr) return 1; - std::unique_ptr Buf = std::move(BufOrErr.get()); + MemoryBuffer &Buf = *BufOrErr.get(); llvm::SourceMgr sm; if (DumpTokens) { - yaml::dumpTokens(Buf->getBuffer(), outs()); + yaml::dumpTokens(Buf.getBuffer(), outs()); } if (DumpCanonical) { - yaml::Stream stream(Buf->getBuffer(), sm); + yaml::Stream stream(Buf.getBuffer(), sm); dumpStream(stream); } }