[lld] r235747 - Simplify now that there is only one file. NFC.
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 24 12:01:31 PDT 2015
Author: rafael
Date: Fri Apr 24 14:01:30 2015
New Revision: 235747
URL: http://llvm.org/viewvc/llvm-project?rev=235747&view=rev
Log:
Simplify now that there is only one file. NFC.
Modified:
lld/trunk/lib/Driver/DarwinLdDriver.cpp
lld/trunk/lib/ReaderWriter/FileArchive.cpp
lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=235747&r1=235746&r2=235747&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Fri Apr 24 14:01:30 2015
@@ -84,17 +84,17 @@ loadFile(MachOLinkingContext &ctx, Strin
ctx.registry().loadFile(std::move(mbOrErr.get()));
if (std::error_code ec = fileOrErr.getError())
return makeErrorFile(path, ec);
- std::vector<std::unique_ptr<File>> files;
- files.push_back(std::move(fileOrErr.get()));
- for (std::unique_ptr<File> &pf : files) {
- // If file is a dylib, inform LinkingContext about it.
- if (SharedLibraryFile *shl = dyn_cast<SharedLibraryFile>(pf.get())) {
- if (std::error_code ec = shl->parse())
- return makeErrorFile(path, ec);
- ctx.registerDylib(reinterpret_cast<mach_o::MachODylibFile*>(shl),
- upwardDylib);
- }
+ std::unique_ptr<File> &file = fileOrErr.get();
+
+ // If file is a dylib, inform LinkingContext about it.
+ if (SharedLibraryFile *shl = dyn_cast<SharedLibraryFile>(file.get())) {
+ if (std::error_code ec = shl->parse())
+ return makeErrorFile(path, ec);
+ ctx.registerDylib(reinterpret_cast<mach_o::MachODylibFile *>(shl),
+ upwardDylib);
}
+ std::vector<std::unique_ptr<File>> files;
+ files.push_back(std::move(file));
if (wholeArchive)
return parseMemberFiles(files);
return files;
Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=235747&r1=235746&r2=235747&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Fri Apr 24 14:01:30 2015
@@ -177,10 +177,7 @@ private:
_registry.loadFile(std::move(memberMB));
if (std::error_code ec = fileOrErr.getError())
return ec;
- std::vector<std::unique_ptr<File>> files;
- files.push_back(std::move(fileOrErr.get()));
- assert(files.size() == 1);
- result = std::move(files[0]);
+ result = std::move(fileOrErr.get());
if (std::error_code ec = result->parse())
return ec;
result->setArchivePath(_archive->getFileName());
Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=235747&r1=235746&r2=235747&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Fri Apr 24 14:01:30 2015
@@ -627,13 +627,11 @@ MachODylibFile* MachOLinkingContext::loa
registry().loadFile(std::move(mbOrErr.get()));
if (!fileOrErr)
return nullptr;
- std::vector<std::unique_ptr<File>> files;
- files.push_back(std::move(fileOrErr.get()));
- assert(files.size() == 1 && "expected one file in dylib");
- files[0]->parse();
- MachODylibFile* result = reinterpret_cast<MachODylibFile*>(files[0].get());
+ std::unique_ptr<File> &file = fileOrErr.get();
+ file->parse();
+ MachODylibFile *result = reinterpret_cast<MachODylibFile *>(file.get());
// Node object now owned by _indirectDylibs vector.
- _indirectDylibs.push_back(std::move(files[0]));
+ _indirectDylibs.push_back(std::move(file));
return result;
}
More information about the llvm-commits
mailing list