forked from OSchip/llvm-project
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
This commit is contained in:
parent
821a1ac050
commit
f5d9d23905
|
@ -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 Archive::Symbol &Sym) {
|
|||
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(MemoryBufferRef MB, StringRef DefaultSoName) {
|
|||
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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue