From 11ae59f0cee2883307a5c1b67db54a832cc2bc35 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 3 Jul 2019 06:11:50 +0000 Subject: 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. llvm-svn: 365003 --- lld/ELF/ScriptParser.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'lld/ELF/ScriptParser.cpp') diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 0ab2a96c9c8..ab96b8e3773 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/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 ScriptParser::readVersionExtern() { std::vector 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(";"); -- cgit v1.2.3