[ELF] Rename odd variable names "New" after r365730. NFC

New -> newSym or newFlags

Reviewed By: atanasyan

Differential Revision: https://reviews.llvm.org/D66127

llvm-svn: 368651
This commit is contained in:
Fangrui Song 2019-08-13 06:19:39 +00:00
parent 2a09b9acfb
commit ab04ad6af7
6 changed files with 35 additions and 38 deletions

View File

@ -166,17 +166,17 @@ static ArchTreeEdge archTree[] = {
{EF_MIPS_ARCH_2, EF_MIPS_ARCH_1},
};
static bool isArchMatched(uint32_t New, uint32_t res) {
if (New == res)
static bool isArchMatched(uint32_t newFlags, uint32_t res) {
if (newFlags == res)
return true;
if (New == EF_MIPS_ARCH_32 && isArchMatched(EF_MIPS_ARCH_64, res))
if (newFlags == EF_MIPS_ARCH_32 && isArchMatched(EF_MIPS_ARCH_64, res))
return true;
if (New == EF_MIPS_ARCH_32R2 && isArchMatched(EF_MIPS_ARCH_64R2, res))
if (newFlags == EF_MIPS_ARCH_32R2 && isArchMatched(EF_MIPS_ARCH_64R2, res))
return true;
for (const auto &edge : archTree) {
if (res == edge.child) {
res = edge.parent;
if (res == New)
if (res == newFlags)
return true;
}
}
@ -278,18 +278,18 @@ static uint32_t getArchFlags(ArrayRef<FileFlags> files) {
uint32_t ret = files[0].flags & (EF_MIPS_ARCH | EF_MIPS_MACH);
for (const FileFlags &f : files.slice(1)) {
uint32_t New = f.flags & (EF_MIPS_ARCH | EF_MIPS_MACH);
uint32_t newFlags = f.flags & (EF_MIPS_ARCH | EF_MIPS_MACH);
// Check ISA compatibility.
if (isArchMatched(New, ret))
if (isArchMatched(newFlags, ret))
continue;
if (!isArchMatched(ret, New)) {
if (!isArchMatched(ret, newFlags)) {
error("incompatible target ISA:\n>>> " + toString(files[0].file) + ": " +
getFullArchName(ret) + "\n>>> " + toString(f.file) + ": " +
getFullArchName(New));
getFullArchName(newFlags));
return 0;
}
ret = New;
ret = newFlags;
}
return ret;
}

View File

@ -1475,10 +1475,10 @@ static Symbol *createBitcodeSymbol(const std::vector<bool> &keptComdats,
int c = objSym.getComdatIndex();
if (objSym.isUndefined() || (c != -1 && !keptComdats[c])) {
Undefined New(&f, name, binding, visibility, type);
Undefined newSym(&f, name, binding, visibility, type);
if (canOmitFromDynSym)
New.exportDynamic = false;
return symtab->addSymbol(New);
newSym.exportDynamic = false;
return symtab->addSymbol(newSym);
}
if (objSym.isCommon())
@ -1486,10 +1486,10 @@ static Symbol *createBitcodeSymbol(const std::vector<bool> &keptComdats,
CommonSymbol{&f, name, binding, visibility, STT_OBJECT,
objSym.getCommonAlignment(), objSym.getCommonSize()});
Defined New(&f, name, binding, visibility, type, 0, 0, nullptr);
Defined newSym(&f, name, binding, visibility, type, 0, 0, nullptr);
if (canOmitFromDynSym)
New.exportDynamic = false;
return symtab->addSymbol(New);
newSym.exportDynamic = false;
return symtab->addSymbol(newSym);
}
template <class ELFT> void BitcodeFile::parse() {

View File

@ -181,12 +181,12 @@ void LinkerScript::addSymbol(SymbolAssignment *cmd) {
// write expressions like this: `alignment = 16; . = ALIGN(., alignment)`.
uint64_t symValue = value.sec ? 0 : value.getValue();
Defined New(nullptr, cmd->name, STB_GLOBAL, visibility, STT_NOTYPE, symValue,
0, sec);
Defined newSym(nullptr, cmd->name, STB_GLOBAL, visibility, STT_NOTYPE,
symValue, 0, sec);
Symbol *sym = symtab->insert(cmd->name);
sym->mergeProperties(New);
sym->replace(New);
sym->mergeProperties(newSym);
sym->replace(newSym);
cmd->sym = cast<Defined>(sym);
}
@ -197,13 +197,13 @@ static void declareSymbol(SymbolAssignment *cmd) {
return;
uint8_t visibility = cmd->hidden ? STV_HIDDEN : STV_DEFAULT;
Defined New(nullptr, cmd->name, STB_GLOBAL, visibility, STT_NOTYPE, 0, 0,
nullptr);
Defined newSym(nullptr, cmd->name, STB_GLOBAL, visibility, STT_NOTYPE, 0, 0,
nullptr);
// We can't calculate final value right now.
Symbol *sym = symtab->insert(cmd->name);
sym->mergeProperties(New);
sym->replace(New);
sym->mergeProperties(newSym);
sym->replace(newSym);
cmd->sym = cast<Defined>(sym);
cmd->provide = false;

View File

@ -83,9 +83,9 @@ Symbol *SymbolTable::insert(StringRef name) {
return sym;
}
Symbol *SymbolTable::addSymbol(const Symbol &New) {
Symbol *sym = symtab->insert(New.getName());
sym->resolve(New);
Symbol *SymbolTable::addSymbol(const Symbol &newSym) {
Symbol *sym = symtab->insert(newSym.getName());
sym->resolve(newSym);
return sym;
}

View File

@ -43,7 +43,7 @@ public:
Symbol *insert(StringRef name);
Symbol *addSymbol(const Symbol &New);
Symbol *addSymbol(const Symbol &newSym);
void scanVersionScript();

View File

@ -135,7 +135,7 @@ public:
// True if this symbol is specified by --trace-symbol option.
unsigned traced : 1;
inline void replace(const Symbol &New);
inline void replace(const Symbol &newSym);
bool includeInDynsym() const;
uint8_t computeBinding() const;
@ -511,7 +511,7 @@ size_t Symbol::getSymbolSize() const {
// replace() replaces "this" object with a given symbol by memcpy'ing
// it over to "this". This function is called as a result of name
// resolution, e.g. to replace an undefind symbol with a defined symbol.
void Symbol::replace(const Symbol &New) {
void Symbol::replace(const Symbol &newSym) {
using llvm::ELF::STT_TLS;
// Symbols representing thread-local variables must be referenced by
@ -519,16 +519,13 @@ void Symbol::replace(const Symbol &New) {
// non-TLS relocations, so there's a clear distinction between TLS
// and non-TLS symbols. It is an error if the same symbol is defined
// as a TLS symbol in one file and as a non-TLS symbol in other file.
if (symbolKind != PlaceholderKind && !isLazy() && !New.isLazy()) {
bool tlsMismatch = (type == STT_TLS && New.type != STT_TLS) ||
(type != STT_TLS && New.type == STT_TLS);
if (tlsMismatch)
error("TLS attribute mismatch: " + toString(*this) + "\n>>> defined in " +
toString(New.file) + "\n>>> defined in " + toString(file));
}
if (symbolKind != PlaceholderKind && !isLazy() && !newSym.isLazy() &&
(type == STT_TLS) != (newSym.type == STT_TLS))
error("TLS attribute mismatch: " + toString(*this) + "\n>>> defined in " +
toString(newSym.file) + "\n>>> defined in " + toString(file));
Symbol old = *this;
memcpy(this, &New, New.getSymbolSize());
memcpy(this, &newSym, newSym.getSymbolSize());
versionId = old.versionId;
visibility = old.visibility;