[llvm] r214516 - Remove some calls to std::move.
Rafael Espindola
rafael.espindola at gmail.com
Fri Aug 1 07:31:55 PDT 2014
Author: rafael
Date: Fri Aug 1 09:31:55 2014
New Revision: 214516
URL: http://llvm.org/viewvc/llvm-project?rev=214516&view=rev
Log:
Remove some calls to std::move.
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get
a reference to it.
Thanks to David Blaikie for the suggestion.
Modified:
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/lib/Support/FileUtilities.cpp
llvm/trunk/lib/Support/LockFileManager.cpp
llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
llvm/trunk/tools/llvm-size/llvm-size.cpp
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
llvm/trunk/tools/llvm-vtabledump/llvm-vtabledump.cpp
llvm/trunk/tools/macho-dump/macho-dump.cpp
llvm/trunk/tools/obj2yaml/obj2yaml.cpp
llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp
llvm/trunk/utils/FileCheck/FileCheck.cpp
llvm/trunk/utils/yaml-bench/YAMLBench.cpp
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Fri Aug 1 09:31:55 2014
@@ -307,7 +307,7 @@ uint64_t MCJIT::getSymbolAddress(const s
ChildIt->getAsBinary();
if (ChildBinOrErr.getError())
continue;
- std::unique_ptr<object::Binary> ChildBin = std::move(ChildBinOrErr.get());
+ std::unique_ptr<object::Binary> &ChildBin = ChildBinOrErr.get();
if (ChildBin->isObject()) {
std::unique_ptr<object::ObjectFile> OF(
static_cast<object::ObjectFile *>(ChildBin.release()));
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Fri Aug 1 09:31:55 2014
@@ -635,11 +635,11 @@ static bool ExpandResponseFile(const cha
MemoryBuffer::getFile(FName);
if (!MemBufOrErr)
return false;
- std::unique_ptr<MemoryBuffer> 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<char> BufRef(MemBuf->getBufferStart(), MemBuf->getBufferEnd());
+ ArrayRef<char> BufRef(MemBuf.getBufferStart(), MemBuf.getBufferEnd());
std::string UTF8Buf;
if (hasUTF16ByteOrderMark(BufRef)) {
if (!convertUTF16ToUTF8String(BufRef, UTF8Buf))
Modified: llvm/trunk/lib/Support/FileUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileUtilities.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FileUtilities.cpp (original)
+++ llvm/trunk/lib/Support/FileUtilities.cpp Fri Aug 1 09:31:55 2014
@@ -182,7 +182,7 @@ int llvm::DiffFilesWithTolerance(StringR
*Error = EC.message();
return 2;
}
- std::unique_ptr<MemoryBuffer> F1 = std::move(F1OrErr.get());
+ MemoryBuffer &F1 = *F1OrErr.get();
ErrorOr<std::unique_ptr<MemoryBuffer>> F2OrErr = MemoryBuffer::getFile(NameB);
if (std::error_code EC = F2OrErr.getError()) {
@@ -190,17 +190,17 @@ int llvm::DiffFilesWithTolerance(StringR
*Error = EC.message();
return 2;
}
- std::unique_ptr<MemoryBuffer> 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 &&
Modified: llvm/trunk/lib/Support/LockFileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/LockFileManager.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/lib/Support/LockFileManager.cpp (original)
+++ llvm/trunk/lib/Support/LockFileManager.cpp Fri Aug 1 09:31:55 2014
@@ -39,11 +39,11 @@ LockFileManager::readLockFile(StringRef
sys::fs::remove(LockFileName);
return None;
}
- std::unique_ptr<MemoryBuffer> 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)) {
Modified: llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp Fri Aug 1 09:31:55 2014
@@ -457,8 +457,8 @@ bool SampleModuleProfile::loadText() {
M.getContext().diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));
return false;
}
- std::unique_ptr<MemoryBuffer> 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,
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Fri Aug 1 09:31:55 2014
@@ -703,7 +703,7 @@ writeSymbolTable(raw_fd_ostream &Out, Ar
MemberBuffer, sys::fs::file_magic::unknown, &Context);
if (!ObjOrErr)
continue; // FIXME: check only for "not an object file" errors.
- std::unique_ptr<object::SymbolicFile> 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, Ar
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, Ar
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(Archiv
MemberBuffers.resize(NewMembers.size());
for (unsigned I = 0, N = NewMembers.size(); I < N; ++I) {
- std::unique_ptr<MemoryBuffer> MemberBuffer;
+ std::unique_ptr<MemoryBuffer> &MemberBuffer = MemberBuffers[I];
NewArchiveIterator &Member = NewMembers[I];
if (Member.isNewMember()) {
@@ -781,7 +781,6 @@ static void performWriteOperation(Archiv
failIfError(MemberBufferOrErr.getError());
MemberBuffer = std::move(MemberBufferOrErr.get());
}
- MemberBuffers[I].reset(MemberBuffer.release());
}
if (Symtab) {
Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Fri Aug 1 09:31:55 2014
@@ -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<MemoryBuffer> 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.
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Fri Aug 1 09:31:55 2014
@@ -80,12 +80,12 @@ static void DumpInput(const StringRef &F
errs() << Filename << ": " << EC.message() << '\n';
return;
}
- std::unique_ptr<ObjectFile> Obj = std::move(ObjOrErr.get());
+ ObjectFile &Obj = *ObjOrErr.get();
- std::unique_ptr<DIContext> DICtx(DIContext::getDWARFContext(*Obj));
+ std::unique_ptr<DIContext> 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);
}
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Fri Aug 1 09:31:55 2014
@@ -1013,9 +1013,9 @@ static void dumpSymbolNamesFromFile(std:
createBinary(std::move(*BufferOrErr), &Context);
if (error(BinaryOrErr.getError(), Filename))
return;
- std::unique_ptr<Binary> Bin = std::move(BinaryOrErr.get());
+ Binary &Bin = *BinaryOrErr.get();
- if (Archive *A = dyn_cast<Archive>(Bin.get())) {
+ if (Archive *A = dyn_cast<Archive>(&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:
}
return;
}
- if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(Bin.get())) {
+ if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&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:
ArchiveName.clear();
ArchitectureName.clear();
if (ObjOrErr) {
- std::unique_ptr<ObjectFile> 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:
std::string ArchiveName;
ArchiveName.clear();
if (ObjOrErr) {
- std::unique_ptr<ObjectFile> 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:
ArchiveName.clear();
ArchitectureName.clear();
if (ObjOrErr) {
- std::unique_ptr<ObjectFile> Obj = std::move(ObjOrErr.get());
+ ObjectFile &Obj = *ObjOrErr.get();
if (PrintFileName) {
- if (isa<MachOObjectFile>(Obj.get()) && moreThanOneArch)
+ if (isa<MachOObjectFile>(Obj) && moreThanOneArch)
ArchitectureName = I->getArchTypeName();
} else {
if (moreThanOneArch)
outs() << "\n";
- outs() << Obj->getFileName();
- if (isa<MachOObjectFile>(Obj.get()) && moreThanOneArch)
+ outs() << Obj.getFileName();
+ if (isa<MachOObjectFile>(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:
}
return;
}
- if (SymbolicFile *O = dyn_cast<SymbolicFile>(Bin.get())) {
+ if (SymbolicFile *O = dyn_cast<SymbolicFile>(&Bin)) {
if (!checkMachOAndArchFlags(O, Filename))
return;
dumpSymbolNamesFromObject(*O, true);
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Fri Aug 1 09:31:55 2014
@@ -891,11 +891,11 @@ static void DumpInput(StringRef file) {
errs() << ToolName << ": '" << file << "': " << EC.message() << ".\n";
return;
}
- std::unique_ptr<Binary> binary = std::move(BinaryOrErr.get());
+ Binary &Binary = *BinaryOrErr.get();
- if (Archive *a = dyn_cast<Archive>(binary.get()))
+ if (Archive *a = dyn_cast<Archive>(&Binary))
DumpArchive(a);
- else if (ObjectFile *o = dyn_cast<ObjectFile>(binary.get()))
+ else if (ObjectFile *o = dyn_cast<ObjectFile>(&Binary))
DumpObject(o);
else
errs() << ToolName << ": '" << file << "': " << "Unrecognized file type.\n";
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Fri Aug 1 09:31:55 2014
@@ -292,11 +292,11 @@ static void dumpInput(StringRef File) {
reportError(File, EC);
return;
}
- std::unique_ptr<Binary> Binary = std::move(BinaryOrErr.get());
+ Binary &Binary = *BinaryOrErr.get();
- if (Archive *Arc = dyn_cast<Archive>(Binary.get()))
+ if (Archive *Arc = dyn_cast<Archive>(&Binary))
dumpArchive(Arc);
- else if (ObjectFile *Obj = dyn_cast<ObjectFile>(Binary.get()))
+ else if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
dumpObject(Obj);
else
reportError(File, readobj_error::unrecognized_file_format);
Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Fri Aug 1 09:31:55 2014
@@ -458,9 +458,9 @@ static void PrintFileSectionSizes(String
errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
return;
}
- std::unique_ptr<Binary> binary = std::move(BinaryOrErr.get());
+ Binary &Bin = *BinaryOrErr.get();
- if (Archive *a = dyn_cast<Archive>(binary.get())) {
+ if (Archive *a = dyn_cast<Archive>(&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(String
}
}
} else if (MachOUniversalBinary *UB =
- dyn_cast<MachOUniversalBinary>(binary.get())) {
+ dyn_cast<MachOUniversalBinary>(&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(String
}
}
}
- } else if (ObjectFile *o = dyn_cast<ObjectFile>(binary.get())) {
+ } else if (ObjectFile *o = dyn_cast<ObjectFile>(&Bin)) {
if (!checkMachOAndArchFlags(o, file))
return;
if (OutputFormat == sysv)
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Fri Aug 1 09:31:55 2014
@@ -302,7 +302,7 @@ LLVMSymbolizer::getOrCreateBinary(const
Binary *DbgBin = nullptr;
ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary(Path);
if (!error(BinaryOrErr.getError())) {
- std::unique_ptr<Binary> ParsedBinary = std::move(BinaryOrErr.get());
+ std::unique_ptr<Binary> &ParsedBinary = BinaryOrErr.get();
// Check if it's a universal binary.
Bin = ParsedBinary.get();
ParsedBinariesAndObjects.push_back(std::move(ParsedBinary));
Modified: llvm/trunk/tools/llvm-vtabledump/llvm-vtabledump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-vtabledump/llvm-vtabledump.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-vtabledump/llvm-vtabledump.cpp (original)
+++ llvm/trunk/tools/llvm-vtabledump/llvm-vtabledump.cpp Fri Aug 1 09:31:55 2014
@@ -169,11 +169,11 @@ static void dumpInput(StringRef File) {
reportError(File, EC);
return;
}
- std::unique_ptr<Binary> Binary = std::move(BinaryOrErr.get());
+ Binary &Binary = *BinaryOrErr.get();
- if (Archive *Arc = dyn_cast<Archive>(Binary.get()))
+ if (Archive *Arc = dyn_cast<Archive>(&Binary))
dumpArchive(Arc);
- else if (ObjectFile *Obj = dyn_cast<ObjectFile>(Binary.get()))
+ else if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
dumpVTables(Obj);
else
reportError(File, vtabledump_error::unrecognized_file_format);
Modified: llvm/trunk/tools/macho-dump/macho-dump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/macho-dump/macho-dump.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/macho-dump/macho-dump.cpp (original)
+++ llvm/trunk/tools/macho-dump/macho-dump.cpp Fri Aug 1 09:31:55 2014
@@ -406,9 +406,9 @@ int main(int argc, char **argv) {
ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary(InputFile);
if (std::error_code EC = BinaryOrErr.getError())
return Error("unable to read input: '" + EC.message() + "'");
- std::unique_ptr<Binary> Binary = std::move((BinaryOrErr.get()));
+ Binary &Binary = *BinaryOrErr.get();
- const MachOObjectFile *InputObject = dyn_cast<MachOObjectFile>(Binary.get());
+ const MachOObjectFile *InputObject = dyn_cast<MachOObjectFile>(&Binary);
if (!InputObject)
return Error("Not a MachO object");
Modified: llvm/trunk/tools/obj2yaml/obj2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/obj2yaml.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/obj2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/obj2yaml.cpp Fri Aug 1 09:31:55 2014
@@ -36,9 +36,9 @@ static std::error_code dumpInput(StringR
if (std::error_code EC = BinaryOrErr.getError())
return EC;
- std::unique_ptr<Binary> 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<ObjectFile>(Binary.get()))
+ if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
return dumpObject(*Obj);
return obj2yaml_error::unrecognized_file_format;
Modified: llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp (original)
+++ llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp Fri Aug 1 09:31:55 2014
@@ -153,8 +153,8 @@ std::unique_ptr<Module> TempFile::readBi
return nullptr;
}
- std::unique_ptr<MemoryBuffer> Buffer = std::move(BufferOr.get());
- ErrorOr<Module *> ModuleOr = parseBitcodeFile(Buffer.get(), Context);
+ MemoryBuffer *Buffer = BufferOr.get().get();
+ ErrorOr<Module *> ModuleOr = parseBitcodeFile(Buffer, Context);
if (!ModuleOr) {
DEBUG(dbgs() << "error: " << ModuleOr.getError().message() << "\n");
return nullptr;
Modified: llvm/trunk/utils/FileCheck/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/utils/FileCheck/FileCheck.cpp (original)
+++ llvm/trunk/utils/FileCheck/FileCheck.cpp Fri Aug 1 09:31:55 2014
@@ -1258,7 +1258,7 @@ int main(int argc, char **argv) {
<< "': " << EC.message() << '\n';
return 2;
}
- std::unique_ptr<MemoryBuffer> File = std::move(FileOrErr.get());
+ std::unique_ptr<MemoryBuffer> &File = FileOrErr.get();
if (File->getBufferSize() == 0) {
errs() << "FileCheck error: '" << InputFilename << "' is empty.\n";
Modified: llvm/trunk/utils/yaml-bench/YAMLBench.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/yaml-bench/YAMLBench.cpp?rev=214516&r1=214515&r2=214516&view=diff
==============================================================================
--- llvm/trunk/utils/yaml-bench/YAMLBench.cpp (original)
+++ llvm/trunk/utils/yaml-bench/YAMLBench.cpp Fri Aug 1 09:31:55 2014
@@ -192,15 +192,15 @@ int main(int argc, char **argv) {
MemoryBuffer::getFileOrSTDIN(Input);
if (!BufOrErr)
return 1;
- std::unique_ptr<MemoryBuffer> 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);
}
}
More information about the llvm-commits
mailing list