[lld] 3c6f8ca - [lld] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 24 14:23:35 PDT 2021
Author: Martin Storsjö
Date: 2021-06-25T00:22:01+03:00
New Revision: 3c6f8ca7c9ac99f1606fd0fdd21487675bf3f715
URL: https://github.com/llvm/llvm-project/commit/3c6f8ca7c9ac99f1606fd0fdd21487675bf3f715
DIFF: https://github.com/llvm/llvm-project/commit/3c6f8ca7c9ac99f1606fd0fdd21487675bf3f715.diff
LOG: [lld] Rename StringRef _lower() method calls to _insensitive()
Added:
Modified:
lld/COFF/DebugTypes.cpp
lld/COFF/Driver.cpp
lld/COFF/DriverUtils.cpp
lld/Common/Args.cpp
lld/ELF/Relocations.cpp
lld/ELF/ScriptParser.cpp
lld/MinGW/Driver.cpp
lld/lib/Driver/DarwinLdDriver.cpp
lld/tools/lld/lld.cpp
Removed:
################################################################################
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 5e8bdef5945dc..97be5bc79ac34 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -464,7 +464,7 @@ Error UseTypeServerSource::mergeDebugT(TypeMerger *m) {
static bool equalsPath(StringRef path1, StringRef path2) {
#if defined(_WIN32)
- return path1.equals_lower(path2);
+ return path1.equals_insensitive(path2);
#else
return path1.equals(path2);
#endif
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 97b3c9029e34f..0bf82182ec0f4 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -234,7 +234,7 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
error(filename + ": is not a native COFF file. Recompile without /GL");
break;
case file_magic::pecoff_executable:
- if (filename.endswith_lower(".dll")) {
+ if (filename.endswith_insensitive(".dll")) {
error(filename + ": bad file type. Did you specify a DLL instead of an "
"import library?");
break;
@@ -474,7 +474,7 @@ Optional<StringRef> LinkerDriver::findFile(StringRef filename) {
return None;
}
- if (path.endswith_lower(".lib"))
+ if (path.endswith_insensitive(".lib"))
visitedLibs.insert(std::string(sys::path::filename(path)));
return path;
}
@@ -1142,9 +1142,9 @@ static void parsePDBAltPath(StringRef altPath) {
// text between first and second % as variable name.
buf.append(altPath.substr(cursor, firstMark - cursor));
StringRef var = altPath.substr(firstMark, secondMark - firstMark + 1);
- if (var.equals_lower("%_pdb%"))
+ if (var.equals_insensitive("%_pdb%"))
buf.append(pdbBasename);
- else if (var.equals_lower("%_ext%"))
+ else if (var.equals_insensitive("%_ext%"))
buf.append(binaryExtension);
else {
warn("only %_PDB% and %_EXT% supported in /pdbaltpath:, keeping " +
@@ -1272,8 +1272,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
// If the first command line argument is "/lib", link.exe acts like lib.exe.
// We call our own implementation of lib.exe that understands bitcode files.
- if (argsArr.size() > 1 && (StringRef(argsArr[1]).equals_lower("/lib") ||
- StringRef(argsArr[1]).equals_lower("-lib"))) {
+ if (argsArr.size() > 1 &&
+ (StringRef(argsArr[1]).equals_insensitive("/lib") ||
+ StringRef(argsArr[1]).equals_insensitive("-lib"))) {
if (llvm::libDriverMain(argsArr.slice(1)) != 0)
fatal("lib failed");
return;
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index 0b01a126b1da8..d6261209a9c1c 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -99,17 +99,17 @@ void parseGuard(StringRef fullArg) {
SmallVector<StringRef, 1> splitArgs;
fullArg.split(splitArgs, ",");
for (StringRef arg : splitArgs) {
- if (arg.equals_lower("no"))
+ if (arg.equals_insensitive("no"))
config->guardCF = GuardCFLevel::Off;
- else if (arg.equals_lower("nolongjmp"))
+ else if (arg.equals_insensitive("nolongjmp"))
config->guardCF &= ~GuardCFLevel::LongJmp;
- else if (arg.equals_lower("noehcont"))
+ else if (arg.equals_insensitive("noehcont"))
config->guardCF &= ~GuardCFLevel::EHCont;
- else if (arg.equals_lower("cf"))
+ else if (arg.equals_insensitive("cf"))
config->guardCF = GuardCFLevel::CF;
- else if (arg.equals_lower("longjmp"))
+ else if (arg.equals_insensitive("longjmp"))
config->guardCF |= GuardCFLevel::CF | GuardCFLevel::LongJmp;
- else if (arg.equals_lower("ehcont"))
+ else if (arg.equals_insensitive("ehcont"))
config->guardCF |= GuardCFLevel::CF | GuardCFLevel::EHCont;
else
fatal("invalid argument to /guard: " + arg);
@@ -257,17 +257,17 @@ void parseFunctionPadMin(llvm::opt::Arg *a, llvm::COFF::MachineTypes machine) {
// Parses a string in the form of "EMBED[,=<integer>]|NO".
// Results are directly written to Config.
void parseManifest(StringRef arg) {
- if (arg.equals_lower("no")) {
+ if (arg.equals_insensitive("no")) {
config->manifest = Configuration::No;
return;
}
- if (!arg.startswith_lower("embed"))
+ if (!arg.startswith_insensitive("embed"))
fatal("invalid option " + arg);
config->manifest = Configuration::Embed;
arg = arg.substr(strlen("embed"));
if (arg.empty())
return;
- if (!arg.startswith_lower(",id="))
+ if (!arg.startswith_insensitive(",id="))
fatal("invalid option " + arg);
arg = arg.substr(strlen(",id="));
if (arg.getAsInteger(0, config->manifestID))
@@ -277,7 +277,7 @@ void parseManifest(StringRef arg) {
// Parses a string in the form of "level=<string>|uiAccess=<string>|NO".
// Results are directly written to Config.
void parseManifestUAC(StringRef arg) {
- if (arg.equals_lower("no")) {
+ if (arg.equals_insensitive("no")) {
config->manifestUAC = false;
return;
}
@@ -285,12 +285,12 @@ void parseManifestUAC(StringRef arg) {
arg = arg.ltrim();
if (arg.empty())
return;
- if (arg.startswith_lower("level=")) {
+ if (arg.startswith_insensitive("level=")) {
arg = arg.substr(strlen("level="));
std::tie(config->manifestLevel, arg) = arg.split(" ");
continue;
}
- if (arg.startswith_lower("uiaccess=")) {
+ if (arg.startswith_insensitive("uiaccess=")) {
arg = arg.substr(strlen("uiaccess="));
std::tie(config->manifestUIAccess, arg) = arg.split(" ");
continue;
@@ -305,9 +305,9 @@ void parseSwaprun(StringRef arg) {
do {
StringRef swaprun, newArg;
std::tie(swaprun, newArg) = arg.split(',');
- if (swaprun.equals_lower("cd"))
+ if (swaprun.equals_insensitive("cd"))
config->swaprunCD = true;
- else if (swaprun.equals_lower("net"))
+ else if (swaprun.equals_insensitive("net"))
config->swaprunNet = true;
else if (swaprun.empty())
error("/swaprun: missing argument");
@@ -560,21 +560,21 @@ Export parseExport(StringRef arg) {
while (!rest.empty()) {
StringRef tok;
std::tie(tok, rest) = rest.split(",");
- if (tok.equals_lower("noname")) {
+ if (tok.equals_insensitive("noname")) {
if (e.ordinal == 0)
goto err;
e.noname = true;
continue;
}
- if (tok.equals_lower("data")) {
+ if (tok.equals_insensitive("data")) {
e.data = true;
continue;
}
- if (tok.equals_lower("constant")) {
+ if (tok.equals_insensitive("constant")) {
e.constant = true;
continue;
}
- if (tok.equals_lower("private")) {
+ if (tok.equals_insensitive("private")) {
e.isPrivate = true;
continue;
}
@@ -883,10 +883,11 @@ ParsedDirectives ArgParser::parseDirectives(StringRef s) {
SmallVector<StringRef, 16> tokens;
cl::TokenizeWindowsCommandLineNoCopy(s, saver, tokens);
for (StringRef tok : tokens) {
- if (tok.startswith_lower("/export:") || tok.startswith_lower("-export:"))
+ if (tok.startswith_insensitive("/export:") ||
+ tok.startswith_insensitive("-export:"))
result.exports.push_back(tok.substr(strlen("/export:")));
- else if (tok.startswith_lower("/include:") ||
- tok.startswith_lower("-include:"))
+ else if (tok.startswith_insensitive("/include:") ||
+ tok.startswith_insensitive("-include:"))
result.includes.push_back(tok.substr(strlen("/include:")));
else {
// Copy substrings that are not valid C strings. The tokenizer may have
diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp
index afc57822c5c33..fe7300dd597e5 100644
--- a/lld/Common/Args.cpp
+++ b/lld/Common/Args.cpp
@@ -89,7 +89,7 @@ std::vector<StringRef> lld::args::getLines(MemoryBufferRef mb) {
}
StringRef lld::args::getFilenameWithoutExe(StringRef path) {
- if (path.endswith_lower(".exe"))
+ if (path.endswith_insensitive(".exe"))
return sys::path::stem(path);
return sys::path::filename(path);
}
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 5302d56f14250..ce08ead3fa539 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -820,10 +820,10 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
// Case mismatch, e.g. Foo vs FOO.
for (auto &it : map)
- if (name.equals_lower(it.first))
+ if (name.equals_insensitive(it.first))
return it.second;
for (Symbol *sym : symtab->symbols())
- if (!sym->isUndefined() && name.equals_lower(sym->getName()))
+ if (!sym->isUndefined() && name.equals_insensitive(sym->getName()))
return sym;
// The reference may be a mangled name while the definition is not. Suggest a
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 505e472f904ba..8937bdfe357f9 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -1126,24 +1126,24 @@ Expr ScriptParser::readConstant() {
static Optional<uint64_t> parseInt(StringRef tok) {
// Hexadecimal
uint64_t val;
- if (tok.startswith_lower("0x")) {
+ if (tok.startswith_insensitive("0x")) {
if (!to_integer(tok.substr(2), val, 16))
return None;
return val;
}
- if (tok.endswith_lower("H")) {
+ if (tok.endswith_insensitive("H")) {
if (!to_integer(tok.drop_back(), val, 16))
return None;
return val;
}
// Decimal
- if (tok.endswith_lower("K")) {
+ if (tok.endswith_insensitive("K")) {
if (!to_integer(tok.drop_back(), val, 10))
return None;
return val * 1024;
}
- if (tok.endswith_lower("M")) {
+ if (tok.endswith_insensitive("M")) {
if (!to_integer(tok.drop_back(), val, 10))
return None;
return val * 1024 * 1024;
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index e4abfebfc8a1c..79a62d68dab7e 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -401,7 +401,7 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
for (auto *a : args) {
switch (a->getOption().getID()) {
case OPT_INPUT:
- if (StringRef(a->getValue()).endswith_lower(".def"))
+ if (StringRef(a->getValue()).endswith_insensitive(".def"))
add("-def:" + StringRef(a->getValue()));
else
add(prefix + StringRef(a->getValue()));
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 49f4bdb77a143..f2fbb2aa6896b 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -293,7 +293,7 @@ static llvm::Error loadFileList(StringRef fileListPath,
/// Parse number assuming it is base 16, but allow 0x prefix.
static bool parseNumberBase16(StringRef numStr, uint64_t &baseAddress) {
- if (numStr.startswith_lower("0x"))
+ if (numStr.startswith_insensitive("0x"))
numStr = numStr.drop_front(2);
return numStr.getAsInteger(16, baseAddress);
}
diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp
index 39be1a0bd4edb..143f4c629ea0b 100644
--- a/lld/tools/lld/lld.cpp
+++ b/lld/tools/lld/lld.cpp
@@ -131,7 +131,7 @@ static Flavor parseFlavor(std::vector<const char *> &v) {
// Deduct the flavor from argv[0].
StringRef arg0 = path::filename(v[0]);
- if (arg0.endswith_lower(".exe"))
+ if (arg0.endswith_insensitive(".exe"))
arg0 = arg0.drop_back(4);
return parseProgname(arg0);
}
More information about the llvm-commits
mailing list