From d668873bfe487c8eaec96db927e28de40cf4db5e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 16 May 2019 03:54:41 +0000 Subject: [PATCH] Consistently return `Symbol *` from SymbolTable's add-family functions. llvm-svn: 360845 --- lld/ELF/SymbolTable.cpp | 22 ++++++++++++++-------- lld/ELF/SymbolTable.h | 8 ++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index de3856bdd42a..102a7cf783f4 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -381,7 +381,7 @@ Symbol *SymbolTable::addDefined(const Defined &New) { return Old; } -void SymbolTable::addShared(const SharedSymbol &New) { +Symbol *SymbolTable::addShared(const SharedSymbol &New) { Symbol *Old = insert(New); mergeProperties(Old, New); @@ -391,7 +391,7 @@ void SymbolTable::addShared(const SharedSymbol &New) { if (Old->isPlaceholder()) { replaceSymbol(Old, &New); - return; + return Old; } if (Old->Visibility == STV_DEFAULT && (Old->isUndefined() || Old->isLazy())) { @@ -401,6 +401,7 @@ void SymbolTable::addShared(const SharedSymbol &New) { replaceSymbol(Old, &New); Old->Binding = Binding; } + return Old; } Symbol *SymbolTable::addBitcode(const Defined &New) { @@ -429,17 +430,17 @@ Symbol *SymbolTable::find(StringRef Name) { return SymVector[It->second]; } -template void SymbolTable::addLazy(const LazyT &New) { +template Symbol *SymbolTable::addLazy(const LazyT &New) { Symbol *Old = insert(New); mergeProperties(Old, New); if (Old->isPlaceholder()) { replaceSymbol(Old, &New); - return; + return Old; } if (!Old->isUndefined()) - return; + return Old; // An undefined weak will not fetch archive members. See comment on Lazy in // Symbols.h for the details. @@ -448,16 +449,21 @@ template void SymbolTable::addLazy(const LazyT &New) { replaceSymbol(Old, &New); Old->Type = Type; Old->Binding = STB_WEAK; - return; + return Old; } if (InputFile *F = New.fetch()) 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) { if (auto *S = dyn_cast(Sym)) { diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 878cf7d0b03c..eb5fd1f23147 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -47,9 +47,9 @@ public: Symbol *addUndefined(const Undefined &New); Symbol *addDefined(const Defined &New); - void addShared(const SharedSymbol &New); - void addLazyArchive(const LazyArchive &New); - void addLazyObject(const LazyObject &New); + Symbol *addShared(const SharedSymbol &New); + Symbol *addLazyArchive(const LazyArchive &New); + Symbol *addLazyObject(const LazyObject &New); Symbol *addBitcode(const Defined &New); Symbol *addCommon(const CommonSymbol &New); @@ -70,7 +70,7 @@ public: llvm::DenseMap SoNames; private: - template void addLazy(const LazyT &New); + template Symbol *addLazy(const LazyT &New); std::vector findByVersion(SymbolVersion Ver); std::vector findAllByVersion(SymbolVersion Ver);