[lld][ELF] Rename SymbolTable::symbols() to SymbolTable::getSymbols(). NFC

This change renames this method match its original name and the name
used in the wasm linker.

Back in d8f8abbd4a the ELF SymbolTable
method `getSymbols()` was replaced with `forEachSymbol`.

Then in a2fc964417 `forEachSymbol` was
replaced with a `llvm::iterator_range`.

Then in e9262edf0d we came full circle
and the `llvm::iterator_range` was replaced with a `symbols()` accessor
that was identical the original `getSymbols()`.

`getSymbols` also matches the name used elsewhere in the ELF linker as
well as in both COFF and wasm backend (e.g. `InputFiles.h` and
`SyntheticSections.h`)

Differential Revision: https://reviews.llvm.org/D130787
This commit is contained in:
Sam Clegg 2022-07-29 10:16:57 -07:00
parent 57c9780d60
commit 2cd4cd9a32
7 changed files with 16 additions and 16 deletions

View File

@ -1810,7 +1810,7 @@ static void handleUndefinedGlob(StringRef arg) {
// Calling sym->extract() in the loop is not safe because it may add new
// symbols to the symbol table, invalidating the current iterator.
SmallVector<Symbol *, 0> syms;
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (!sym->isPlaceholder() && pat->match(sym->getName()))
syms.push_back(sym);
@ -1996,7 +1996,7 @@ static void replaceCommonSymbols() {
// --no-allow-shlib-undefined diagnostics. Similarly, demote lazy symbols.
static void demoteSharedAndLazySymbols() {
llvm::TimeTraceScope timeScope("Demote shared and lazy symbols");
for (Symbol *sym : symtab->symbols()) {
for (Symbol *sym : symtab->getSymbols()) {
auto *s = dyn_cast<SharedSymbol>(sym);
if (!(s && !cast<SharedFile>(s->file)->isNeeded) && !sym->isLazy())
continue;
@ -2043,7 +2043,7 @@ static void findKeepUniqueSections(opt::InputArgList &args) {
// Symbols in the dynsym could be address-significant in other executables
// or DSOs, so we conservatively mark them as address-significant.
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (sym->includeInDynsym())
markAddrsig(sym);
@ -2301,7 +2301,7 @@ static void redirectSymbols(ArrayRef<WrappedSymbol> wrapped) {
// symbols with a non-default version (foo@v1) and check whether it should be
// combined with foo or foo@@v1.
if (config->versionDefinitions.size() > 2)
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (sym->hasVersionSuffix)
combineVersionedSymbol(*sym, map);

View File

@ -460,7 +460,7 @@ template <class ELFT> void ICF<ELFT>::run() {
// cannot be merged with the later computeIsPreemptible() pass which is used
// by scanRelocations().
if (config->hasDynSymTab)
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
sym->isPreemptible = computeIsPreemptible(*sym);
// Two text sections may have identical content and relocations but different
@ -558,7 +558,7 @@ template <class ELFT> void ICF<ELFT>::run() {
d->folded = true;
}
};
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
fold(sym);
parallelForEach(ctx->objectFiles, [&](ELFFileBase *file) {
for (Symbol *sym : file->getLocalSymbols())

View File

@ -211,7 +211,7 @@ BitcodeCompiler::BitcodeCompiler() {
// Initialize usedStartStop.
if (ctx->bitcodeFiles.empty())
return;
for (Symbol *sym : symtab->symbols()) {
for (Symbol *sym : symtab->getSymbols()) {
if (sym->isPlaceholder())
continue;
StringRef s = sym->getName();

View File

@ -220,7 +220,7 @@ template <class ELFT> void MarkLive<ELFT>::run() {
// Preserve externally-visible symbols if the symbols defined by this
// file can interrupt other ELF file's symbols at runtime.
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (sym->includeInDynsym() && sym->partition == partition)
markSymbol(sym);
@ -361,7 +361,7 @@ template <class ELFT> void elf::markLive() {
// If --gc-sections is not given, retain all input sections.
if (!config->gcSections) {
// If a DSO defines a symbol referenced in a regular object, it is needed.
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (auto *s = dyn_cast<SharedSymbol>(sym))
if (s->isUsedInRegularObj && !s->isWeak())
cast<SharedFile>(s->file)->isNeeded = true;

View File

@ -673,7 +673,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
for (auto &it : map)
if (name.equals_insensitive(it.first))
return it.second;
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (!sym->isUndefined() && name.equals_insensitive(sym->getName()))
return sym;
@ -699,7 +699,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
break;
}
if (!s)
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
if (canSuggestExternCForCXX(name, sym->getName())) {
s = sym;
break;
@ -1697,7 +1697,7 @@ void elf::postScanRelocations() {
}
assert(symAux.empty());
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
fn(*sym);
// Local symbols may need the aforementioned non-preemptible ifunc and GOT

View File

@ -32,7 +32,7 @@ class SharedFile;
// is one add* function per symbol type.
class SymbolTable {
public:
ArrayRef<Symbol *> symbols() const { return symVector; }
ArrayRef<Symbol *> getSymbols() const { return symVector; }
void wrap(Symbol *sym, Symbol *real, Symbol *wrap);

View File

@ -1275,7 +1275,7 @@ static DenseMap<const InputSectionBase *, int> buildSectionOrder() {
// We want both global and local symbols. We get the global ones from the
// symbol table and iterate the object files for the local ones.
for (Symbol *sym : symtab->symbols())
for (Symbol *sym : symtab->getSymbols())
addSym(*sym);
for (ELFFileBase *file : ctx->objectFiles)
@ -1891,7 +1891,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
}
if (config->hasDynSymTab) {
parallelForEach(symtab->symbols(), [](Symbol *sym) {
parallelForEach(symtab->getSymbols(), [](Symbol *sym) {
sym->isPreemptible = computeIsPreemptible(*sym);
});
}
@ -1963,7 +1963,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
llvm::TimeTraceScope timeScope("Add symbols to symtabs");
// Now that we have defined all possible global symbols including linker-
// synthesized ones. Visit all symbols to give the finishing touches.
for (Symbol *sym : symtab->symbols()) {
for (Symbol *sym : symtab->getSymbols()) {
if (!sym->isUsedInRegularObj || !includeInSymtab(*sym))
continue;
if (!config->relocatable)