COFF: Simplify SymbolTable::findLazy. NFC.

llvm-svn: 241128
This commit is contained in:
Rui Ueyama 2015-06-30 23:46:52 +00:00
parent 342b1e8053
commit 4b6698917d
3 changed files with 5 additions and 16 deletions

View File

@ -217,7 +217,8 @@ StringRef LinkerDriver::findDefaultEntry() {
{"wWinMain", "wWinMainCRTStartup"},
};
for (auto E : Entries) {
if (Symtab.findLazy(E[0]))
Symbol *Sym = Symtab.findSymbol(E[0]);
if (Sym && !isa<Undefined>(Sym->Body))
return E[1];
}
return "";

View File

@ -237,23 +237,11 @@ Defined *SymbolTable::find(StringRef Name) {
return nullptr;
}
// Find a given symbol. If a lazy symbol is found,
// resolve that before returning.
Defined *SymbolTable::findLazy(StringRef Name) {
Symbol *SymbolTable::findSymbol(StringRef Name) {
auto It = Symtab.find(Name);
if (It == Symtab.end())
return nullptr;
Symbol *Sym = It->second;
if (auto *B = dyn_cast<Defined>(Sym->Body))
return B;
if (auto *B = dyn_cast<Lazy>(Sym->Body)) {
if (addMemberFile(B))
return nullptr;
if (run())
return nullptr;
return cast<Defined>(Sym->Body);
}
return nullptr;
return It->second;
}
// Find a given symbol or its mangled symbol.

View File

@ -59,7 +59,7 @@ public:
// mechanisms to allow aliases, a name can be resolved to a
// different symbol). Returns a nullptr if not found.
Defined *find(StringRef Name);
Defined *findLazy(StringRef Name);
Symbol *findSymbol(StringRef Name);
// Find a symbol assuming that Name is a function name.
// Not only a given string but its mangled names (in MSVC C++ manner)