Consistently return `Symbol *` from SymbolTable's add-family functions.

llvm-svn: 360845
This commit is contained in:
Rui Ueyama 2019-05-16 03:54:41 +00:00
parent 943cd00580
commit d668873bfe
2 changed files with 18 additions and 12 deletions

View File

@ -381,7 +381,7 @@ Symbol *SymbolTable::addDefined(const Defined &New) {
return Old; return Old;
} }
void SymbolTable::addShared(const SharedSymbol &New) { Symbol *SymbolTable::addShared(const SharedSymbol &New) {
Symbol *Old = insert(New); Symbol *Old = insert(New);
mergeProperties(Old, New); mergeProperties(Old, New);
@ -391,7 +391,7 @@ void SymbolTable::addShared(const SharedSymbol &New) {
if (Old->isPlaceholder()) { if (Old->isPlaceholder()) {
replaceSymbol(Old, &New); replaceSymbol(Old, &New);
return; return Old;
} }
if (Old->Visibility == STV_DEFAULT && (Old->isUndefined() || Old->isLazy())) { if (Old->Visibility == STV_DEFAULT && (Old->isUndefined() || Old->isLazy())) {
@ -401,6 +401,7 @@ void SymbolTable::addShared(const SharedSymbol &New) {
replaceSymbol(Old, &New); replaceSymbol(Old, &New);
Old->Binding = Binding; Old->Binding = Binding;
} }
return Old;
} }
Symbol *SymbolTable::addBitcode(const Defined &New) { Symbol *SymbolTable::addBitcode(const Defined &New) {
@ -429,17 +430,17 @@ Symbol *SymbolTable::find(StringRef Name) {
return SymVector[It->second]; return SymVector[It->second];
} }
template <class LazyT> void SymbolTable::addLazy(const LazyT &New) { template <class LazyT> Symbol *SymbolTable::addLazy(const LazyT &New) {
Symbol *Old = insert(New); Symbol *Old = insert(New);
mergeProperties(Old, New); mergeProperties(Old, New);
if (Old->isPlaceholder()) { if (Old->isPlaceholder()) {
replaceSymbol(Old, &New); replaceSymbol(Old, &New);
return; return Old;
} }
if (!Old->isUndefined()) if (!Old->isUndefined())
return; return Old;
// An undefined weak will not fetch archive members. See comment on Lazy in // An undefined weak will not fetch archive members. See comment on Lazy in
// Symbols.h for the details. // Symbols.h for the details.
@ -448,16 +449,21 @@ template <class LazyT> void SymbolTable::addLazy(const LazyT &New) {
replaceSymbol(Old, &New); replaceSymbol(Old, &New);
Old->Type = Type; Old->Type = Type;
Old->Binding = STB_WEAK; Old->Binding = STB_WEAK;
return; return Old;
} }
if (InputFile *F = New.fetch()) if (InputFile *F = New.fetch())
parseFile(F); parseFile(F);
return Old;
} }
void SymbolTable::addLazyArchive(const LazyArchive &New) { addLazy(New); } Symbol *SymbolTable::addLazyArchive(const LazyArchive &New) {
return addLazy(New);
}
void SymbolTable::addLazyObject(const LazyObject &New) { addLazy(New); } Symbol *SymbolTable::addLazyObject(const LazyObject &New) {
return addLazy(New);
}
void SymbolTable::fetchLazy(Symbol *Sym) { void SymbolTable::fetchLazy(Symbol *Sym) {
if (auto *S = dyn_cast<LazyArchive>(Sym)) { if (auto *S = dyn_cast<LazyArchive>(Sym)) {

View File

@ -47,9 +47,9 @@ public:
Symbol *addUndefined(const Undefined &New); Symbol *addUndefined(const Undefined &New);
Symbol *addDefined(const Defined &New); Symbol *addDefined(const Defined &New);
void addShared(const SharedSymbol &New); Symbol *addShared(const SharedSymbol &New);
void addLazyArchive(const LazyArchive &New); Symbol *addLazyArchive(const LazyArchive &New);
void addLazyObject(const LazyObject &New); Symbol *addLazyObject(const LazyObject &New);
Symbol *addBitcode(const Defined &New); Symbol *addBitcode(const Defined &New);
Symbol *addCommon(const CommonSymbol &New); Symbol *addCommon(const CommonSymbol &New);
@ -70,7 +70,7 @@ public:
llvm::DenseMap<StringRef, SharedFile *> SoNames; llvm::DenseMap<StringRef, SharedFile *> SoNames;
private: private:
template <class LazyT> void addLazy(const LazyT &New); template <class LazyT> Symbol *addLazy(const LazyT &New);
std::vector<Symbol *> findByVersion(SymbolVersion Ver); std::vector<Symbol *> findByVersion(SymbolVersion Ver);
std::vector<Symbol *> findAllByVersion(SymbolVersion Ver); std::vector<Symbol *> findAllByVersion(SymbolVersion Ver);