Skip to content

Commit f5d9d23

Browse files
committed
Simplify InputFile::fetch().
We don't have to return a value from the function. Instead, we can directly call parseFile from the functions. llvm-svn: 361478
1 parent 821a1ac commit f5d9d23

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,14 +1010,14 @@ void ArchiveFile::parse() {
10101010
}
10111011

10121012
// Returns a buffer pointing to a member file containing a given symbol.
1013-
InputFile *ArchiveFile::fetch(const Archive::Symbol &Sym) {
1013+
void ArchiveFile::fetch(const Archive::Symbol &Sym) {
10141014
Archive::Child C =
10151015
CHECK(Sym.getMember(), toString(this) +
10161016
": could not get the member for symbol " +
10171017
Sym.getName());
10181018

10191019
if (!Seen.insert(C.getChildOffset()).second)
1020-
return nullptr;
1020+
return;
10211021

10221022
MemoryBufferRef MB =
10231023
CHECK(C.getMemoryBufferRef(),
@@ -1031,7 +1031,7 @@ InputFile *ArchiveFile::fetch(const Archive::Symbol &Sym) {
10311031
InputFile *File = createObjectFile(
10321032
MB, getName(), C.getParent()->isThin() ? 0 : C.getChildOffset());
10331033
File->GroupId = GroupId;
1034-
return File;
1034+
parseFile(File);
10351035
}
10361036

10371037
unsigned SharedFile::VernauxNum;
@@ -1469,9 +1469,9 @@ InputFile *elf::createSharedFile(MemoryBufferRef MB, StringRef DefaultSoName) {
14691469
return F;
14701470
}
14711471

1472-
InputFile *LazyObjFile::fetch() {
1472+
void LazyObjFile::fetch() {
14731473
if (MB.getBuffer().empty())
1474-
return nullptr;
1474+
return;
14751475

14761476
InputFile *File = createObjectFile(MB, ArchiveName, OffsetInArchive);
14771477
File->GroupId = GroupId;
@@ -1481,7 +1481,8 @@ InputFile *LazyObjFile::fetch() {
14811481
// Copy symbol vector so that the new InputFile doesn't have to
14821482
// insert the same defined symbols to the symbol table again.
14831483
File->Symbols = std::move(Symbols);
1484-
return File;
1484+
1485+
parseFile(File);
14851486
}
14861487

14871488
template <class ELFT> void LazyObjFile::parse() {

lld/ELF/InputFiles.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class LazyObjFile : public InputFile {
307307
static bool classof(const InputFile *F) { return F->kind() == LazyObjKind; }
308308

309309
template <class ELFT> void parse();
310-
InputFile *fetch();
310+
void fetch();
311311

312312
private:
313313
uint64_t OffsetInArchive;
@@ -322,9 +322,9 @@ class ArchiveFile : public InputFile {
322322

323323
// Pulls out an object file that contains a definition for Sym and
324324
// returns it. If the same file was instantiated before, this
325-
// function returns a nullptr (so we don't instantiate the same file
325+
// function does nothing (so we don't instantiate the same file
326326
// more than once.)
327-
InputFile *fetch(const Archive::Symbol &Sym);
327+
void fetch(const Archive::Symbol &Sym);
328328

329329
private:
330330
std::unique_ptr<Archive> File;

lld/ELF/Symbols.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,12 @@ void Symbol::parseSymbolVersion() {
243243

244244
void Symbol::fetch() const {
245245
if (auto *Sym = dyn_cast<LazyArchive>(this)) {
246-
if (auto *F = cast<ArchiveFile>(Sym->File)->fetch(Sym->Sym))
247-
parseFile(F);
246+
cast<ArchiveFile>(Sym->File)->fetch(Sym->Sym);
248247
return;
249248
}
250249

251250
if (auto *Sym = dyn_cast<LazyObject>(this)) {
252-
if (auto *F = dyn_cast<LazyObjFile>(Sym->File)->fetch())
253-
parseFile(F);
251+
dyn_cast<LazyObjFile>(Sym->File)->fetch();
254252
return;
255253
}
256254

0 commit comments

Comments
 (0)