From f483da00387650ef9b196da3530dde821c7c527b Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 3 Nov 2017 22:48:47 +0000 Subject: [PATCH] Rename replaceBody -> replaceSymbol. llvm-svn: 317383 --- lld/COFF/LTO.cpp | 2 +- lld/COFF/SymbolTable.cpp | 25 +++++++++++++------------ lld/COFF/Symbols.h | 2 +- lld/COFF/Writer.cpp | 2 +- lld/ELF/LTO.cpp | 4 ++-- lld/ELF/LinkerScript.cpp | 4 ++-- lld/ELF/SymbolTable.cpp | 26 +++++++++++++------------- lld/ELF/Symbols.h | 2 +- lld/ELF/SyntheticSections.cpp | 6 +++--- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp index d7573d8..fa2a54b 100644 --- a/lld/COFF/LTO.cpp +++ b/lld/COFF/LTO.cpp @@ -88,7 +88,7 @@ BitcodeCompiler::BitcodeCompiler() : LTOObj(createLTO()) {} BitcodeCompiler::~BitcodeCompiler() = default; -static void undefine(Symbol *S) { replaceBody(S, S->getName()); } +static void undefine(Symbol *S) { replaceSymbol(S, S->getName()); } void BitcodeCompiler::add(BitcodeFile &F) { lto::InputFile &Obj = *F.Obj; diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 1372e2e..040dbf5 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -126,7 +126,7 @@ void SymbolTable::reportRemainingUndefines() { Symbol *Imp = find(Name.substr(strlen("__imp_"))); if (Imp && isa(Imp)) { auto *D = cast(Imp); - replaceBody(Sym, Name, D); + replaceSymbol(Sym, Name, D); LocalImportChunks.push_back(cast(Sym)->getChunk()); continue; } @@ -135,7 +135,7 @@ void SymbolTable::reportRemainingUndefines() { // Remaining undefined symbols are not fatal if /force is specified. // They are replaced with dummy defined symbols. if (Config->Force) - replaceBody(Sym, Name, 0); + replaceSymbol(Sym, Name, 0); Undefs.insert(Sym); } @@ -170,7 +170,7 @@ Symbol *SymbolTable::addUndefined(StringRef Name, InputFile *F, if (!F || !isa(F)) S->IsUsedInRegularObj = true; if (WasInserted || (isa(S) && IsWeakAlias)) { - replaceBody(S, Name); + replaceSymbol(S, Name); return S; } if (auto *L = dyn_cast(S)) { @@ -188,7 +188,7 @@ void SymbolTable::addLazy(ArchiveFile *F, const Archive::Symbol Sym) { bool WasInserted; std::tie(S, WasInserted) = insert(Name); if (WasInserted) { - replaceBody(S, F, Sym); + replaceSymbol(S, F, Sym); return; } auto *U = dyn_cast(S); @@ -210,7 +210,7 @@ Symbol *SymbolTable::addAbsolute(StringRef N, COFFSymbolRef Sym) { std::tie(S, WasInserted) = insert(N); S->IsUsedInRegularObj = true; if (WasInserted || isa(S) || isa(S)) - replaceBody(S, N, Sym); + replaceSymbol(S, N, Sym); else if (!isa(S)) reportDuplicate(S, nullptr); return S; @@ -222,7 +222,7 @@ Symbol *SymbolTable::addAbsolute(StringRef N, uint64_t VA) { std::tie(S, WasInserted) = insert(N); S->IsUsedInRegularObj = true; if (WasInserted || isa(S) || isa(S)) - replaceBody(S, N, VA); + replaceSymbol(S, N, VA); else if (!isa(S)) reportDuplicate(S, nullptr); return S; @@ -234,7 +234,7 @@ Symbol *SymbolTable::addSynthetic(StringRef N, Chunk *C) { std::tie(S, WasInserted) = insert(N); S->IsUsedInRegularObj = true; if (WasInserted || isa(S) || isa(S)) - replaceBody(S, N, C); + replaceSymbol(S, N, C); else if (!isa(S)) reportDuplicate(S, nullptr); return S; @@ -252,7 +252,8 @@ Symbol *SymbolTable::addRegular(InputFile *F, StringRef N, bool IsCOMDAT, if (SP == SP_CONFLICT) { reportDuplicate(S, F); } else if (SP == SP_NEW) { - replaceBody(S, F, N, IsCOMDAT, /*IsExternal*/ true, Sym, C); + replaceSymbol(S, F, N, IsCOMDAT, /*IsExternal*/ true, Sym, + C); } else if (SP == SP_EXISTING && IsCOMDAT && C) { C->markDiscarded(); // Discard associative chunks that we've parsed so far. No need to recurse @@ -271,10 +272,10 @@ Symbol *SymbolTable::addCommon(InputFile *F, StringRef N, uint64_t Size, if (!isa(F)) S->IsUsedInRegularObj = true; if (WasInserted || !isa(S)) - replaceBody(S, F, N, Size, Sym, C); + replaceSymbol(S, F, N, Size, Sym, C); else if (auto *DC = dyn_cast(S)) if (Size > DC->getSize()) - replaceBody(S, F, N, Size, Sym, C); + replaceSymbol(S, F, N, Size, Sym, C); return S; } @@ -284,7 +285,7 @@ DefinedImportData *SymbolTable::addImportData(StringRef N, ImportFile *F) { std::tie(S, WasInserted) = insert(N); S->IsUsedInRegularObj = true; if (WasInserted || isa(S) || isa(S)) { - replaceBody(S, N, F); + replaceSymbol(S, N, F); return cast(S); } @@ -300,7 +301,7 @@ DefinedImportThunk *SymbolTable::addImportThunk(StringRef Name, std::tie(S, WasInserted) = insert(Name); S->IsUsedInRegularObj = true; if (WasInserted || isa(S) || isa(S)) { - replaceBody(S, Name, ID, Machine); + replaceSymbol(S, Name, ID, Machine); return cast(S); } diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h index 9cb595c..6dce4d2 100644 --- a/lld/COFF/Symbols.h +++ b/lld/COFF/Symbols.h @@ -412,7 +412,7 @@ union SymbolUnion { }; template -void replaceBody(Symbol *S, ArgT &&... Arg) { +void replaceSymbol(Symbol *S, ArgT &&... Arg) { static_assert(sizeof(T) <= sizeof(SymbolUnion), "Symbol too small"); static_assert(alignof(T) <= alignof(SymbolUnion), "SymbolUnion not aligned enough"); diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index b5d02c3..781afee 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -806,7 +806,7 @@ void Writer::fixSafeSEHSymbols() { // section relative relocations. Symbol *T = Symtab->find("___safe_se_handler_table"); Symbol *C = Symtab->find("___safe_se_handler_count"); - replaceBody(T, T->getName(), SEHTable); + replaceSymbol(T, T->getName(), SEHTable); cast(C)->setVA(SEHTable->getSize() / 4); } diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index 29598ca..f6f61fa 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -119,8 +119,8 @@ BitcodeCompiler::BitcodeCompiler() : LTOObj(createLTO()) { BitcodeCompiler::~BitcodeCompiler() = default; static void undefine(Symbol *S) { - replaceBody(S, nullptr, S->getName(), /*IsLocal=*/false, - STV_DEFAULT, S->Type); + replaceSymbol(S, nullptr, S->getName(), /*IsLocal=*/false, + STV_DEFAULT, S->Type); } void BitcodeCompiler::add(BitcodeFile &F) { diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 87fcfd5..6c32442 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -149,8 +149,8 @@ void LinkerScript::addSymbol(SymbolAssignment *Cmd) { // write expressions like this: `alignment = 16; . = ALIGN(., alignment)`. uint64_t SymValue = Value.Sec ? 0 : Value.getValue(); - replaceBody(Sym, nullptr, Cmd->Name, /*IsLocal=*/false, - Visibility, STT_NOTYPE, SymValue, 0, Sec); + replaceSymbol(Sym, nullptr, Cmd->Name, /*IsLocal=*/false, + Visibility, STT_NOTYPE, SymValue, 0, Sec); Cmd->Sym = cast(Sym); } diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 02b16b6..4eec9dc 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -315,7 +315,7 @@ Symbol *SymbolTable::addUndefined(StringRef Name, bool IsLocal, uint8_t Binding, // in the same DSO. if (WasInserted || (isa(S) && Visibility != STV_DEFAULT)) { S->Binding = Binding; - replaceBody(S, File, Name, IsLocal, StOther, Type); + replaceSymbol(S, File, Name, IsLocal, StOther, Type); return S; } if (Binding != STB_WEAK) { @@ -404,7 +404,7 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment, int Cmp = compareDefined(S, WasInserted, Binding, N); if (Cmp > 0) { S->Binding = Binding; - replaceBody(S, File, N, Size, Alignment, StOther, Type); + replaceSymbol(S, File, N, Size, Alignment, StOther, Type); } else if (Cmp == 0) { auto *C = dyn_cast(S); if (!C) { @@ -419,7 +419,7 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment, Alignment = C->Alignment = std::max(C->Alignment, Alignment); if (Size > C->Size) - replaceBody(S, File, N, Size, Alignment, StOther, Type); + replaceSymbol(S, File, N, Size, Alignment, StOther, Type); } return S; } @@ -480,8 +480,8 @@ Symbol *SymbolTable::addRegular(StringRef Name, uint8_t StOther, uint8_t Type, int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, Section == nullptr, Value, Name); if (Cmp > 0) - replaceBody(S, File, Name, /*IsLocal=*/false, StOther, Type, - Value, Size, Section); + replaceSymbol(S, File, Name, /*IsLocal=*/false, StOther, + Type, Value, Size, Section); else if (Cmp == 0) reportDuplicate(S, dyn_cast_or_null(Section), Value); @@ -507,8 +507,8 @@ void SymbolTable::addShared(StringRef Name, SharedFile *File, // in the same DSO. if (WasInserted || ((S->isUndefined() || S->isLazy()) && S->getVisibility() == STV_DEFAULT)) { - replaceBody(S, File, Name, Sym.st_other, Sym.getType(), - Sym.st_value, Sym.st_size, Alignment, Verdef); + replaceSymbol(S, File, Name, Sym.st_other, Sym.getType(), + Sym.st_value, Sym.st_size, Alignment, Verdef); if (!S->isWeak()) File->IsUsed = true; } @@ -524,8 +524,8 @@ Symbol *SymbolTable::addBitcode(StringRef Name, uint8_t Binding, int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, /*IsAbs*/ false, /*Value*/ 0, Name); if (Cmp > 0) - replaceBody(S, F, Name, /*IsLocal=*/false, StOther, Type, 0, - 0, nullptr); + replaceSymbol(S, F, Name, /*IsLocal=*/false, StOther, Type, + 0, 0, nullptr); else if (Cmp == 0) reportDuplicate(S, F); return S; @@ -559,7 +559,7 @@ Symbol *SymbolTable::addLazyArchive(StringRef Name, ArchiveFile *F, bool WasInserted; std::tie(S, WasInserted) = insert(Name); if (WasInserted) { - replaceBody(S, F, Sym, Symbol::UnknownType); + replaceSymbol(S, F, Sym, Symbol::UnknownType); return S; } if (!S->isUndefined()) @@ -568,7 +568,7 @@ Symbol *SymbolTable::addLazyArchive(StringRef Name, ArchiveFile *F, // An undefined weak will not fetch archive members. See comment on Lazy in // Symbols.h for the details. if (S->isWeak()) { - replaceBody(S, F, Sym, S->Type); + replaceSymbol(S, F, Sym, S->Type); return S; } std::pair MBInfo = F->getMember(&Sym); @@ -583,7 +583,7 @@ void SymbolTable::addLazyObject(StringRef Name, LazyObjFile &Obj) { bool WasInserted; std::tie(S, WasInserted) = insert(Name); if (WasInserted) { - replaceBody(S, &Obj, Name, Symbol::UnknownType); + replaceSymbol(S, &Obj, Name, Symbol::UnknownType); return; } if (!S->isUndefined()) @@ -591,7 +591,7 @@ void SymbolTable::addLazyObject(StringRef Name, LazyObjFile &Obj) { // See comment for addLazyArchive above. if (S->isWeak()) - replaceBody(S, &Obj, Name, S->Type); + replaceSymbol(S, &Obj, Name, S->Type); else if (InputFile *F = Obj.fetch()) addFile(F); } diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index a741bd7..5769f52 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -388,7 +388,7 @@ union SymbolUnion { void printTraceSymbol(Symbol *Sym); template -void replaceBody(Symbol *S, InputFile *File, ArgT &&... Arg) { +void replaceSymbol(Symbol *S, InputFile *File, ArgT &&... Arg) { static_assert(sizeof(T) <= sizeof(SymbolUnion), "SymbolUnion too small"); static_assert(alignof(T) <= alignof(SymbolUnion), "SymbolUnion not aligned enough"); diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 4299289..96d2551 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -80,9 +80,9 @@ template void elf::createCommonSections() { // Replace all DefinedCommon symbols with DefinedRegular symbols so that we // don't have to care about DefinedCommon symbols beyond this point. - replaceBody(S, Sym->getFile(), Sym->getName(), - static_cast(Sym->isLocal()), Sym->StOther, - Sym->Type, 0, Sym->getSize(), Section); + replaceSymbol( + S, Sym->getFile(), Sym->getName(), static_cast(Sym->isLocal()), + Sym->StOther, Sym->Type, 0, Sym->getSize(), Section); } } -- 2.7.4