Skip to content

Commit

Permalink
[lldb] Rename StringRef _lower() method calls to _insensitive()
Browse files Browse the repository at this point in the history
  • Loading branch information
mstorsjo committed Jun 24, 2021
1 parent 3c6f8ca commit e50f9c4
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 51 deletions.
2 changes: 1 addition & 1 deletion lldb/source/Commands/CommandObjectMultiword.cpp
Expand Up @@ -98,7 +98,7 @@ bool CommandObjectMultiword::Execute(const char *args_string,
return result.Succeeded();
}

if (sub_command.equals_lower("help")) {
if (sub_command.equals_insensitive("help")) {
this->CommandObject::GenerateHelpText(result);
return result.Succeeded();
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Host/common/NativeRegisterContext.cpp
Expand Up @@ -60,8 +60,8 @@ NativeRegisterContext::GetRegisterInfoByName(llvm::StringRef reg_name,
for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);

if (reg_name.equals_lower(reg_info->name) ||
reg_name.equals_lower(reg_info->alt_name))
if (reg_name.equals_insensitive(reg_info->name) ||
reg_name.equals_insensitive(reg_info->alt_name))
return reg_info;
}
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/windows/ProcessLauncherWindows.cpp
Expand Up @@ -86,7 +86,7 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
const char *hide_console_var =
getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
if (hide_console_var &&
llvm::StringRef(hide_console_var).equals_lower("true")) {
llvm::StringRef(hide_console_var).equals_insensitive("true")) {
startupinfo.dwFlags |= STARTF_USESHOWWINDOW;
startupinfo.wShowWindow = SW_HIDE;
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Initialization/SystemInitializerCommon.cpp
Expand Up @@ -96,7 +96,7 @@ llvm::Error SystemInitializerCommon::Initialize() {
#if defined(_WIN32)
const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
if (disable_crash_dialog_var &&
llvm::StringRef(disable_crash_dialog_var).equals_lower("true")) {
llvm::StringRef(disable_crash_dialog_var).equals_insensitive("true")) {
// This will prevent Windows from displaying a dialog box requiring user
// interaction when
// LLDB crashes. This is mostly useful when automating LLDB, for example
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/CommandInterpreter.cpp
Expand Up @@ -2675,7 +2675,7 @@ void CommandInterpreter::FindCommandsForApropos(
const bool search_long_help = false;
const bool search_syntax = false;
const bool search_options = false;
if (command_name.contains_lower(search_word) ||
if (command_name.contains_insensitive(search_word) ||
cmd_obj->HelpTextContainsWord(search_word, search_short_help,
search_long_help, search_syntax,
search_options)) {
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Interpreter/CommandObject.cpp
Expand Up @@ -316,11 +316,11 @@ bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
llvm::StringRef long_help = GetHelpLong();
llvm::StringRef syntax_help = GetSyntax();

if (search_short_help && short_help.contains_lower(search_word))
if (search_short_help && short_help.contains_insensitive(search_word))
found_word = true;
else if (search_long_help && long_help.contains_lower(search_word))
else if (search_long_help && long_help.contains_insensitive(search_word))
found_word = true;
else if (search_syntax && syntax_help.contains_lower(search_word))
else if (search_syntax && syntax_help.contains_insensitive(search_word))
found_word = true;

if (!found_word && search_options && GetOptions() != nullptr) {
Expand All @@ -330,7 +330,7 @@ bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
if (!usage_help.Empty()) {
llvm::StringRef usage_text = usage_help.GetString();
if (usage_text.contains_lower(search_word))
if (usage_text.contains_insensitive(search_word))
found_word = true;
}
}
Expand Down
16 changes: 8 additions & 8 deletions lldb/source/Interpreter/OptionArgParser.cpp
Expand Up @@ -20,11 +20,11 @@ bool OptionArgParser::ToBoolean(llvm::StringRef ref, bool fail_value,
if (success_ptr)
*success_ptr = true;
ref = ref.trim();
if (ref.equals_lower("false") || ref.equals_lower("off") ||
ref.equals_lower("no") || ref.equals_lower("0")) {
if (ref.equals_insensitive("false") || ref.equals_insensitive("off") ||
ref.equals_insensitive("no") || ref.equals_insensitive("0")) {
return false;
} else if (ref.equals_lower("true") || ref.equals_lower("on") ||
ref.equals_lower("yes") || ref.equals_lower("1")) {
} else if (ref.equals_insensitive("true") || ref.equals_insensitive("on") ||
ref.equals_insensitive("yes") || ref.equals_insensitive("1")) {
return true;
}
if (success_ptr)
Expand Down Expand Up @@ -125,13 +125,13 @@ lldb::ScriptLanguage OptionArgParser::ToScriptLanguage(
if (success_ptr)
*success_ptr = true;

if (s.equals_lower("python"))
if (s.equals_insensitive("python"))
return eScriptLanguagePython;
if (s.equals_lower("lua"))
if (s.equals_insensitive("lua"))
return eScriptLanguageLua;
if (s.equals_lower("default"))
if (s.equals_insensitive("default"))
return eScriptLanguageDefault;
if (s.equals_lower("none"))
if (s.equals_insensitive("none"))
return eScriptLanguageNone;

if (success_ptr)
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Interpreter/OptionValueProperties.cpp
Expand Up @@ -630,11 +630,11 @@ void OptionValueProperties::Apropos(
} else {
bool match = false;
llvm::StringRef name = property->GetName();
if (name.contains_lower(keyword))
if (name.contains_insensitive(keyword))
match = true;
else {
llvm::StringRef desc = property->GetDescription();
if (desc.contains_lower(keyword))
if (desc.contains_insensitive(keyword))
match = true;
}
if (match) {
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Interpreter/ScriptInterpreter.cpp
Expand Up @@ -85,11 +85,11 @@ ScriptInterpreter::GetStatusFromSBError(const lldb::SBError &error) const {

lldb::ScriptLanguage
ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
if (language.equals_insensitive(LanguageToString(eScriptLanguageNone)))
return eScriptLanguageNone;
if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
if (language.equals_insensitive(LanguageToString(eScriptLanguagePython)))
return eScriptLanguagePython;
if (language.equals_lower(LanguageToString(eScriptLanguageLua)))
if (language.equals_insensitive(LanguageToString(eScriptLanguageLua)))
return eScriptLanguageLua;
return eScriptLanguageUnknown;
}
Expand Down
Expand Up @@ -1152,7 +1152,7 @@ bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
const auto suffixes = {".cpp", ".cxx", ".c++", ".cc", ".c",
".h", ".hh", ".hpp", ".hxx", ".h++"};
for (auto suffix : suffixes) {
if (file_path.endswith_lower(suffix))
if (file_path.endswith_insensitive(suffix))
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
Expand Up @@ -1134,7 +1134,7 @@ bool ObjCLanguage::IsNilReference(ValueObject &valobj) {
bool ObjCLanguage::IsSourceFile(llvm::StringRef file_path) const {
const auto suffixes = {".h", ".m", ".M"};
for (auto suffix : suffixes) {
if (file_path.endswith_lower(suffix))
if (file_path.endswith_insensitive(suffix))
return true;
}
return false;
Expand Down
Expand Up @@ -19,7 +19,7 @@ LLDB_PLUGIN_DEFINE(ObjCPlusPlusLanguage)
bool ObjCPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
const auto suffixes = {".h", ".mm"};
for (auto suffix : suffixes) {
if (file_path.endswith_lower(suffix))
if (file_path.endswith_insensitive(suffix))
return true;
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
Expand Up @@ -86,10 +86,10 @@ ProcessSP ProcessWindows::CreateInstance(lldb::TargetSP target_sp,

static bool ShouldUseLLDBServer() {
llvm::StringRef use_lldb_server = ::getenv("LLDB_USE_LLDB_SERVER");
return use_lldb_server.equals_lower("on") ||
use_lldb_server.equals_lower("yes") ||
use_lldb_server.equals_lower("1") ||
use_lldb_server.equals_lower("true");
return use_lldb_server.equals_insensitive("on") ||
use_lldb_server.equals_insensitive("yes") ||
use_lldb_server.equals_insensitive("1") ||
use_lldb_server.equals_insensitive("true");
}

void ProcessWindows::Initialize() {
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
Expand Up @@ -548,7 +548,7 @@ void ProcessMinidump::ReadModuleList() {

// check if the process is wow64 - a 32 bit windows process running on a
// 64 bit windows
if (llvm::StringRef(name).endswith_lower("wow64.dll")) {
if (llvm::StringRef(name).endswith_insensitive("wow64.dll")) {
m_is_wow64 = true;
}

Expand Down
Expand Up @@ -43,7 +43,7 @@ static bool IsMainFile(llvm::StringRef main, llvm::StringRef other) {

llvm::SmallString<64> normalized(other);
llvm::sys::path::native(normalized);
return main.equals_lower(normalized);
return main.equals_insensitive(normalized);
}

static void ParseCompile3(const CVSymbol &sym, CompilandIndexItem &cci) {
Expand Down
Expand Up @@ -41,7 +41,7 @@ static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, llvm::Triple::A
auto it = llvm::find_if(
register_names,
[&reg_name](const llvm::EnumEntry<uint16_t> &register_entry) {
return reg_name.compare_lower(register_entry.Name) == 0;
return reg_name.compare_insensitive(register_entry.Name) == 0;
});

if (it == register_names.end())
Expand Down
6 changes: 4 additions & 2 deletions lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
Expand Up @@ -84,8 +84,10 @@ bool ShouldAddLine(uint32_t requested_line, uint32_t actual_line,
static bool ShouldUseNativeReader() {
#if defined(_WIN32)
llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
return use_native.equals_lower("on") || use_native.equals_lower("yes") ||
use_native.equals_lower("1") || use_native.equals_lower("true");
return use_native.equals_insensitive("on") ||
use_native.equals_insensitive("yes") ||
use_native.equals_insensitive("1") ||
use_native.equals_insensitive("true");
#else
return true;
#endif
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/Language.cpp
Expand Up @@ -196,7 +196,7 @@ static uint32_t num_languages =

LanguageType Language::GetLanguageTypeFromString(llvm::StringRef string) {
for (const auto &L : language_names) {
if (string.equals_lower(L.name))
if (string.equals_insensitive(L.name))
return static_cast<LanguageType>(L.type);
}

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/RegisterContext.cpp
Expand Up @@ -58,8 +58,8 @@ RegisterContext::GetRegisterInfoByName(llvm::StringRef reg_name,
for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);

if (reg_name.equals_lower(reg_info->name) ||
reg_name.equals_lower(reg_info->alt_name))
if (reg_name.equals_insensitive(reg_info->name) ||
reg_name.equals_insensitive(reg_info->alt_name))
return reg_info;
}
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Utility/ArchSpec.cpp
Expand Up @@ -464,7 +464,7 @@ static const ArchDefinition *FindArchDefinition(ArchitectureType arch_type) {
// Get an architecture definition by name.
static const CoreDefinition *FindCoreDefinition(llvm::StringRef name) {
for (unsigned int i = 0; i < llvm::array_lengthof(g_core_definitions); ++i) {
if (name.equals_lower(g_core_definitions[i].name))
if (name.equals_insensitive(g_core_definitions[i].name))
return &g_core_definitions[i];
}
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Utility/ConstString.cpp
Expand Up @@ -253,7 +253,7 @@ bool ConstString::Equals(ConstString lhs, ConstString rhs,
// perform case insensitive equality test
llvm::StringRef lhs_string_ref(lhs.GetStringRef());
llvm::StringRef rhs_string_ref(rhs.GetStringRef());
return lhs_string_ref.equals_lower(rhs_string_ref);
return lhs_string_ref.equals_insensitive(rhs_string_ref);
}

int ConstString::Compare(ConstString lhs, ConstString rhs,
Expand All @@ -270,7 +270,7 @@ int ConstString::Compare(ConstString lhs, ConstString rhs,
if (case_sensitive) {
return lhs_string_ref.compare(rhs_string_ref);
} else {
return lhs_string_ref.compare_lower(rhs_string_ref);
return lhs_string_ref.compare_insensitive(rhs_string_ref);
}
}

Expand Down
10 changes: 5 additions & 5 deletions lldb/source/Utility/FileSpec.cpp
Expand Up @@ -499,9 +499,9 @@ void FileSpec::MakeAbsolute(const FileSpec &dir) {
void llvm::format_provider<FileSpec>::format(const FileSpec &F,
raw_ostream &Stream,
StringRef Style) {
assert(
(Style.empty() || Style.equals_lower("F") || Style.equals_lower("D")) &&
"Invalid FileSpec style!");
assert((Style.empty() || Style.equals_insensitive("F") ||
Style.equals_insensitive("D")) &&
"Invalid FileSpec style!");

StringRef dir = F.GetDirectory().GetStringRef();
StringRef file = F.GetFilename().GetStringRef();
Expand All @@ -511,7 +511,7 @@ void llvm::format_provider<FileSpec>::format(const FileSpec &F,
return;
}

if (Style.equals_lower("F")) {
if (Style.equals_insensitive("F")) {
Stream << (file.empty() ? "(empty)" : file);
return;
}
Expand All @@ -527,7 +527,7 @@ void llvm::format_provider<FileSpec>::format(const FileSpec &F,
Stream << GetPreferredPathSeparator(F.GetPathStyle());
}

if (Style.equals_lower("D")) {
if (Style.equals_insensitive("D")) {
// We only want to print the directory, so now just exit.
if (dir.empty())
Stream << "(empty)";
Expand Down
11 changes: 6 additions & 5 deletions lldb/source/Utility/Log.cpp
Expand Up @@ -60,17 +60,18 @@ uint32_t Log::GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &
bool list_categories = false;
uint32_t flags = 0;
for (const char *category : categories) {
if (llvm::StringRef("all").equals_lower(category)) {
if (llvm::StringRef("all").equals_insensitive(category)) {
flags |= UINT32_MAX;
continue;
}
if (llvm::StringRef("default").equals_lower(category)) {
if (llvm::StringRef("default").equals_insensitive(category)) {
flags |= entry.second.m_channel.default_flags;
continue;
}
auto cat = llvm::find_if(
entry.second.m_channel.categories,
[&](const Log::Category &c) { return c.name.equals_lower(category); });
auto cat = llvm::find_if(entry.second.m_channel.categories,
[&](const Log::Category &c) {
return c.name.equals_insensitive(category);
});
if (cat != entry.second.m_channel.categories.end()) {
flags |= cat->flag;
continue;
Expand Down

0 comments on commit e50f9c4

Please sign in to comment.