aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-07-03 06:11:50 +0000
committerRui Ueyama <ruiu@google.com>2019-07-03 06:11:50 +0000
commitc5f0d6290b37244c992b6dbd6971b60930b4a4c7 (patch)
tree2844851b62798597c5f924790cd15dc47029e241
parent338a34cbcd80615c5e6bebec65613249e7074984 (diff)
Avoid identifiers that are different only in case. NFC.
Some variables in lld have the same name as functions ignoring case. This patch gives them different names, so that my next patch is easier to read. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@365003 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/DWARF.cpp6
-rw-r--r--ELF/InputFiles.cpp10
-rw-r--r--ELF/Relocations.cpp8
-rw-r--r--ELF/ScriptParser.cpp32
-rw-r--r--ELF/Symbols.cpp12
5 files changed, 33 insertions, 35 deletions
diff --git a/ELF/DWARF.cpp b/ELF/DWARF.cpp
index 3c2c7f70f..58ac056b7 100644
--- a/ELF/DWARF.cpp
+++ b/ELF/DWARF.cpp
@@ -58,7 +58,7 @@ namespace {
template <class RelTy> struct LLDRelocationResolver {
// In the ELF ABIs, S sepresents the value of the symbol in the relocation
// entry. For Rela, the addend is stored as part of the relocation entry.
- static uint64_t Resolve(object::RelocationRef Ref, uint64_t S,
+ static uint64_t resolve(object::RelocationRef Ref, uint64_t S,
uint64_t /* A */) {
return S + Ref.getRawDataRefImpl().p;
}
@@ -66,7 +66,7 @@ template <class RelTy> struct LLDRelocationResolver {
template <class ELFT> struct LLDRelocationResolver<Elf_Rel_Impl<ELFT, false>> {
// For Rel, the addend A is supplied by the caller.
- static uint64_t Resolve(object::RelocationRef /*Ref*/, uint64_t S,
+ static uint64_t resolve(object::RelocationRef /*Ref*/, uint64_t S,
uint64_t A) {
return S + A;
}
@@ -110,7 +110,7 @@ LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos,
DataRefImpl D;
D.p = getAddend<ELFT>(Rel);
return RelocAddrEntry{SecIndex, RelocationRef(D, nullptr),
- LLDRelocationResolver<RelTy>::Resolve, Val};
+ LLDRelocationResolver<RelTy>::resolve, Val};
}
template <class ELFT>
diff --git a/ELF/InputFiles.cpp b/ELF/InputFiles.cpp
index e7bbfa19d..4d65ef372 100644
--- a/ELF/InputFiles.cpp
+++ b/ELF/InputFiles.cpp
@@ -55,7 +55,7 @@ static ELFKind getELFKind(MemoryBufferRef MB, StringRef ArchiveName) {
unsigned char Endian;
std::tie(Size, Endian) = getElfArchType(MB.getBuffer());
- auto Fatal = [&](StringRef Msg) {
+ auto Report = [&](StringRef Msg) {
StringRef Filename = MB.getBufferIdentifier();
if (ArchiveName.empty())
fatal(Filename + ": " + Msg);
@@ -64,16 +64,16 @@ static ELFKind getELFKind(MemoryBufferRef MB, StringRef ArchiveName) {
};
if (!MB.getBuffer().startswith(ElfMagic))
- Fatal("not an ELF file");
+ Report("not an ELF file");
if (Endian != ELFDATA2LSB && Endian != ELFDATA2MSB)
- Fatal("corrupted ELF file: invalid data encoding");
+ Report("corrupted ELF file: invalid data encoding");
if (Size != ELFCLASS32 && Size != ELFCLASS64)
- Fatal("corrupted ELF file: invalid file class");
+ Report("corrupted ELF file: invalid file class");
size_t BufSize = MB.getBuffer().size();
if ((Size == ELFCLASS32 && BufSize < sizeof(Elf32_Ehdr)) ||
(Size == ELFCLASS64 && BufSize < sizeof(Elf64_Ehdr)))
- Fatal("corrupted ELF file: file is too short");
+ Report("corrupted ELF file: file is too short");
if (Size == ELFCLASS32)
return (Endian == ELFDATA2LSB) ? ELF32LEKind : ELF32BEKind;
diff --git a/ELF/Relocations.cpp b/ELF/Relocations.cpp
index 61080eca7..bdd4d7cdc 100644
--- a/ELF/Relocations.cpp
+++ b/ELF/Relocations.cpp
@@ -566,10 +566,10 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol &SS) {
// See if this symbol is in a read-only segment. If so, preserve the symbol's
// memory protection by reserving space in the .bss.rel.ro section.
- bool IsReadOnly = isReadOnly<ELFT>(SS);
- BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss",
- SymSize, SS.Alignment);
- if (IsReadOnly)
+ bool IsRO = isReadOnly<ELFT>(SS);
+ BssSection *Sec =
+ make<BssSection>(IsRO ? ".bss.rel.ro" : ".bss", SymSize, SS.Alignment);
+ if (IsRO)
In.BssRelRo->getParent()->addSection(Sec);
else
In.Bss->getParent()->addSection(Sec);
diff --git a/ELF/ScriptParser.cpp b/ELF/ScriptParser.cpp
index 0ab2a96c9..ab96b8e37 100644
--- a/ELF/ScriptParser.cpp
+++ b/ELF/ScriptParser.cpp
@@ -40,14 +40,21 @@ using namespace llvm::support::endian;
using namespace lld;
using namespace lld::elf;
-static bool isUnderSysroot(StringRef Path);
-
namespace {
class ScriptParser final : ScriptLexer {
public:
- ScriptParser(MemoryBufferRef MB)
- : ScriptLexer(MB),
- IsUnderSysroot(isUnderSysroot(MB.getBufferIdentifier())) {}
+ ScriptParser(MemoryBufferRef MB) : ScriptLexer(MB) {
+ // Initialize IsUnderSysroot
+ if (Config->Sysroot == "")
+ return;
+ StringRef Path = MB.getBufferIdentifier();
+ for (; !Path.empty(); Path = sys::path::parent_path(Path)) {
+ if (!sys::fs::equivalent(Config->Sysroot, Path))
+ continue;
+ IsUnderSysroot = true;
+ return;
+ }
+ }
void readLinkerScript();
void readVersionScript();
@@ -118,7 +125,7 @@ private:
readSymbols();
// True if a script being read is in a subdirectory specified by -sysroot.
- bool IsUnderSysroot;
+ bool IsUnderSysroot = false;
// A set to detect an INCLUDE() cycle.
StringSet<> Seen;
@@ -131,15 +138,6 @@ static StringRef unquote(StringRef S) {
return S;
}
-static bool isUnderSysroot(StringRef Path) {
- if (Config->Sysroot == "")
- return false;
- for (; !Path.empty(); Path = sys::path::parent_path(Path))
- if (sys::fs::equivalent(Config->Sysroot, Path))
- return true;
- return false;
-}
-
// Some operations only support one non absolute value. Move the
// absolute one to the right hand side for convenience.
static void moveAbsRight(ExprValue &A, ExprValue &B) {
@@ -1449,8 +1447,8 @@ std::vector<SymbolVersion> ScriptParser::readVersionExtern() {
std::vector<SymbolVersion> Ret;
while (!errorCount() && peek() != "}") {
StringRef Tok = next();
- bool HasWildcard = !Tok.startswith("\"") && hasWildcard(Tok);
- Ret.push_back({unquote(Tok), IsCXX, HasWildcard});
+ Ret.push_back(
+ {unquote(Tok), IsCXX, !Tok.startswith("\"") && hasWildcard(Tok)});
if (consume("}"))
return Ret;
expect(";");
diff --git a/ELF/Symbols.cpp b/ELF/Symbols.cpp
index 00ecc4152..172bdf178 100644
--- a/ELF/Symbols.cpp
+++ b/ELF/Symbols.cpp
@@ -317,18 +317,18 @@ void elf::maybeWarnUnorderableSymbol(const Symbol *Sym) {
const InputFile *File = Sym->File;
auto *D = dyn_cast<Defined>(Sym);
- auto Warn = [&](StringRef S) { warn(toString(File) + S + Sym->getName()); };
+ auto Report = [&](StringRef S) { warn(toString(File) + S + Sym->getName()); };
if (Sym->isUndefined())
- Warn(": unable to order undefined symbol: ");
+ Report(": unable to order undefined symbol: ");
else if (Sym->isShared())
- Warn(": unable to order shared symbol: ");
+ Report(": unable to order shared symbol: ");
else if (D && !D->Section)
- Warn(": unable to order absolute symbol: ");
+ Report(": unable to order absolute symbol: ");
else if (D && isa<OutputSection>(D->Section))
- Warn(": unable to order synthetic symbol: ");
+ Report(": unable to order synthetic symbol: ");
else if (D && !D->Section->Repl->isLive())
- Warn(": unable to order discarded symbol: ");
+ Report(": unable to order discarded symbol: ");
}
// Returns a symbol for an error message.