[lld] r361478 - Simplify InputFile::fetch().
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 03:15:12 PDT 2019
Author: ruiu
Date: Thu May 23 03:15:12 2019
New Revision: 361478
URL: http://llvm.org/viewvc/llvm-project?rev=361478&view=rev
Log:
Simplify InputFile::fetch().
We don't have to return a value from the function. Instead, we can
directly call parseFile from the functions.
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/ELF/Symbols.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=361478&r1=361477&r2=361478&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu May 23 03:15:12 2019
@@ -1010,14 +1010,14 @@ void ArchiveFile::parse() {
}
// Returns a buffer pointing to a member file containing a given symbol.
-InputFile *ArchiveFile::fetch(const Archive::Symbol &Sym) {
+void ArchiveFile::fetch(const Archive::Symbol &Sym) {
Archive::Child C =
CHECK(Sym.getMember(), toString(this) +
": could not get the member for symbol " +
Sym.getName());
if (!Seen.insert(C.getChildOffset()).second)
- return nullptr;
+ return;
MemoryBufferRef MB =
CHECK(C.getMemoryBufferRef(),
@@ -1031,7 +1031,7 @@ InputFile *ArchiveFile::fetch(const Arch
InputFile *File = createObjectFile(
MB, getName(), C.getParent()->isThin() ? 0 : C.getChildOffset());
File->GroupId = GroupId;
- return File;
+ parseFile(File);
}
unsigned SharedFile::VernauxNum;
@@ -1469,9 +1469,9 @@ InputFile *elf::createSharedFile(MemoryB
return F;
}
-InputFile *LazyObjFile::fetch() {
+void LazyObjFile::fetch() {
if (MB.getBuffer().empty())
- return nullptr;
+ return;
InputFile *File = createObjectFile(MB, ArchiveName, OffsetInArchive);
File->GroupId = GroupId;
@@ -1481,7 +1481,8 @@ InputFile *LazyObjFile::fetch() {
// Copy symbol vector so that the new InputFile doesn't have to
// insert the same defined symbols to the symbol table again.
File->Symbols = std::move(Symbols);
- return File;
+
+ parseFile(File);
}
template <class ELFT> void LazyObjFile::parse() {
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=361478&r1=361477&r2=361478&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Thu May 23 03:15:12 2019
@@ -307,7 +307,7 @@ public:
static bool classof(const InputFile *F) { return F->kind() == LazyObjKind; }
template <class ELFT> void parse();
- InputFile *fetch();
+ void fetch();
private:
uint64_t OffsetInArchive;
@@ -322,9 +322,9 @@ public:
// Pulls out an object file that contains a definition for Sym and
// returns it. If the same file was instantiated before, this
- // function returns a nullptr (so we don't instantiate the same file
+ // function does nothing (so we don't instantiate the same file
// more than once.)
- InputFile *fetch(const Archive::Symbol &Sym);
+ void fetch(const Archive::Symbol &Sym);
private:
std::unique_ptr<Archive> File;
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=361478&r1=361477&r2=361478&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Thu May 23 03:15:12 2019
@@ -243,14 +243,12 @@ void Symbol::parseSymbolVersion() {
void Symbol::fetch() const {
if (auto *Sym = dyn_cast<LazyArchive>(this)) {
- if (auto *F = cast<ArchiveFile>(Sym->File)->fetch(Sym->Sym))
- parseFile(F);
+ cast<ArchiveFile>(Sym->File)->fetch(Sym->Sym);
return;
}
if (auto *Sym = dyn_cast<LazyObject>(this)) {
- if (auto *F = dyn_cast<LazyObjFile>(Sym->File)->fetch())
- parseFile(F);
+ dyn_cast<LazyObjFile>(Sym->File)->fetch();
return;
}
More information about the llvm-commits
mailing list