Author: Kazu Hirata Date: 2024-05-16T20:47:12-07:00 New Revision: c33922666ce219fd6cb3341c3394f72050599552
URL: https://github.com/llvm/llvm-project/commit/c33922666ce219fd6cb3341c3394f72050599552 DIFF: https://github.com/llvm/llvm-project/commit/c33922666ce219fd6cb3341c3394f72050599552.diff LOG: [lldb] Use operator==(StringRef, StringRef) instead of StringRef::equals (NFC) (#92476) Note that StringRef::equals has been deprecated in favor of operator==(StringRef, StringRef). Added: Modified: lldb/source/Commands/CommandObjectThread.cpp lldb/source/Core/FormatEntity.cpp lldb/source/Expression/IRExecutionUnit.cpp lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp lldb/source/Plugins/Language/ObjC/Cocoa.cpp lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Target/PathMappingList.cpp Removed: ################################################################################ diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 3dbbfd4f9d344..4397ee14ea074 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -151,14 +151,14 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { for (size_t idx = 0; idx < num_entries; idx++) { llvm::StringRef arg_string = copy_args[idx].ref(); - if (arg_string.equals("-c") || count_opt.starts_with(arg_string)) { + if (arg_string == "-c" || count_opt.starts_with(arg_string)) { idx++; if (idx == num_entries) return std::nullopt; count_idx = idx; if (copy_args[idx].ref().getAsInteger(0, count_val)) return std::nullopt; - } else if (arg_string.equals("-s") || start_opt.starts_with(arg_string)) { + } else if (arg_string == "-s" || start_opt.starts_with(arg_string)) { idx++; if (idx == num_entries) return std::nullopt; diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 07978d3882961..1c3a4cb1062fe 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1921,7 +1921,7 @@ static Status ParseEntry(const llvm::StringRef &format_str, const size_t n = parent->num_children; for (size_t i = 0; i < n; ++i) { const Definition *entry_def = parent->children + i; - if (key.equals(entry_def->name) || entry_def->name[0] == '*') { + if (key == entry_def->name || entry_def->name[0] == '*') { llvm::StringRef value; if (sep_char) value = @@ -2002,7 +2002,7 @@ static const Definition *FindEntry(const llvm::StringRef &format_str, const size_t n = parent->num_children; for (size_t i = 0; i < n; ++i) { const Definition *entry_def = parent->children + i; - if (p.first.equals(entry_def->name) || entry_def->name[0] == '*') { + if (p.first == entry_def->name || entry_def->name[0] == '*') { if (p.second.empty()) { if (format_str.back() == '.') remainder = format_str.drop_front(format_str.size() - 1); @@ -2351,13 +2351,13 @@ Status FormatEntity::ExtractVariableInfo(llvm::StringRef &format_str, bool FormatEntity::FormatFileSpec(const FileSpec &file_spec, Stream &s, llvm::StringRef variable_name, llvm::StringRef variable_format) { - if (variable_name.empty() || variable_name.equals(".fullpath")) { + if (variable_name.empty() || variable_name == ".fullpath") { file_spec.Dump(s.AsRawOstream()); return true; - } else if (variable_name.equals(".basename")) { + } else if (variable_name == ".basename") { s.PutCString(file_spec.GetFilename().GetStringRef()); return true; - } else if (variable_name.equals(".dirname")) { + } else if (variable_name == ".dirname") { s.PutCString(file_spec.GetFilename().GetStringRef()); return true; } @@ -2440,7 +2440,7 @@ void FormatEntity::AutoComplete(CompletionRequest &request) { // "${thread.id" <TAB> request.AddCompletion(MakeMatch(str, "}")); } - } else if (remainder.equals(".")) { + } else if (remainder == ".") { // "${thread." <TAB> StringList new_matches; AddMatches(entry_def, str, llvm::StringRef(), new_matches); diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 07df8c52a2a4f..f220704423627 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -534,63 +534,63 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( } if (!name.empty()) { - if (name.equals("__text") || name.equals(".text")) + if (name == "__text" || name == ".text") sect_type = lldb::eSectionTypeCode; - else if (name.equals("__data") || name.equals(".data")) + else if (name == "__data" || name == ".data") sect_type = lldb::eSectionTypeCode; else if (name.starts_with("__debug_") || name.starts_with(".debug_")) { const uint32_t name_idx = name[0] == '_' ? 8 : 7; llvm::StringRef dwarf_name(name.substr(name_idx)); switch (dwarf_name[0]) { case 'a': - if (dwarf_name.equals("abbrev")) + if (dwarf_name == "abbrev") sect_type = lldb::eSectionTypeDWARFDebugAbbrev; - else if (dwarf_name.equals("aranges")) + else if (dwarf_name == "aranges") sect_type = lldb::eSectionTypeDWARFDebugAranges; - else if (dwarf_name.equals("addr")) + else if (dwarf_name == "addr") sect_type = lldb::eSectionTypeDWARFDebugAddr; break; case 'f': - if (dwarf_name.equals("frame")) + if (dwarf_name == "frame") sect_type = lldb::eSectionTypeDWARFDebugFrame; break; case 'i': - if (dwarf_name.equals("info")) + if (dwarf_name == "info") sect_type = lldb::eSectionTypeDWARFDebugInfo; break; case 'l': - if (dwarf_name.equals("line")) + if (dwarf_name == "line") sect_type = lldb::eSectionTypeDWARFDebugLine; - else if (dwarf_name.equals("loc")) + else if (dwarf_name == "loc") sect_type = lldb::eSectionTypeDWARFDebugLoc; - else if (dwarf_name.equals("loclists")) + else if (dwarf_name == "loclists") sect_type = lldb::eSectionTypeDWARFDebugLocLists; break; case 'm': - if (dwarf_name.equals("macinfo")) + if (dwarf_name == "macinfo") sect_type = lldb::eSectionTypeDWARFDebugMacInfo; break; case 'p': - if (dwarf_name.equals("pubnames")) + if (dwarf_name == "pubnames") sect_type = lldb::eSectionTypeDWARFDebugPubNames; - else if (dwarf_name.equals("pubtypes")) + else if (dwarf_name == "pubtypes") sect_type = lldb::eSectionTypeDWARFDebugPubTypes; break; case 's': - if (dwarf_name.equals("str")) + if (dwarf_name == "str") sect_type = lldb::eSectionTypeDWARFDebugStr; - else if (dwarf_name.equals("str_offsets")) + else if (dwarf_name == "str_offsets") sect_type = lldb::eSectionTypeDWARFDebugStrOffsets; break; case 'r': - if (dwarf_name.equals("ranges")) + if (dwarf_name == "ranges") sect_type = lldb::eSectionTypeDWARFDebugRanges; break; @@ -599,7 +599,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( } } else if (name.starts_with("__apple_") || name.starts_with(".apple_")) sect_type = lldb::eSectionTypeInvalid; - else if (name.equals("__objc_imageinfo")) + else if (name == "__objc_imageinfo") sect_type = lldb::eSectionTypeOther; } return sect_type; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 597873af8b2ae..cc9bd14c6194e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -1449,7 +1449,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) { Argument *argument = &*iter; - if (argument->getName().equals("this")) { + if (argument->getName() == "this") { ++iter; if (iter == llvm_function.arg_end()) { @@ -1461,7 +1461,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) { } argument = &*iter; - } else if (argument->getName().equals("self")) { + } else if (argument->getName() == "self") { ++iter; if (iter == llvm_function.arg_end()) { @@ -1472,7 +1472,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) { return false; } - if (!iter->getName().equals("_cmd")) { + if (iter->getName() != "_cmd") { m_error_stream.Format("Internal error [IRForTarget]: Wrapper takes '{0}' " "after 'self' argument (should take '_cmd')", iter->getName()); @@ -1493,7 +1493,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) { argument = &*iter; } - if (!argument->getName().equals("$__lldb_arg")) { + if (argument->getName() != "$__lldb_arg") { m_error_stream.Format("Internal error [IRForTarget]: Wrapper takes an " "argument named '{0}' instead of the struct pointer", argument->getName()); diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index 96166657ceeb6..341923108e321 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -802,7 +802,7 @@ bool lldb_private::formatters::NSURLSummaryProvider( llvm::StringRef class_name = descriptor->GetClassName().GetStringRef(); - if (!class_name.equals("NSURL")) + if (class_name != "NSURL") return false; uint64_t offset_text = ptr_size + ptr_size + diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index d88f2d0830192..5c6b475044be5 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -3557,7 +3557,7 @@ ObjectFile::Strata ObjectFileELF::CalculateStrata() { // decrease by one llvm::StringRef loader_name(buffer, read_size - 1); llvm::StringRef freebsd_kernel_loader_name("/red/herring"); - if (loader_name.equals(freebsd_kernel_loader_name)) + if (loader_name == freebsd_kernel_loader_name) return eStrataKernel; } } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index db9fb37a9a3c3..74e392249a94e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1052,10 +1052,10 @@ bool GDBRemoteCommunicationClient::GetGDBServerVersion() { llvm::StringRef name, value; bool success = false; while (response.GetNameColonValue(name, value)) { - if (name.equals("name")) { + if (name == "name") { success = true; m_gdb_server_name = std::string(value); - } else if (name.equals("version")) { + } else if (name == "version") { llvm::StringRef major, minor; std::tie(major, minor) = value.split('.'); if (!major.getAsInteger(0, m_gdb_server_version)) @@ -1192,12 +1192,12 @@ bool GDBRemoteCommunicationClient::GetDefaultThreadId(lldb::tid_t &tid) { static void ParseOSType(llvm::StringRef value, std::string &os_name, std::string &environment) { - if (value.equals("iossimulator") || value.equals("tvossimulator") || - value.equals("watchossimulator") || value.equals("xrossimulator") || - value.equals("visionossimulator")) { + if (value == "iossimulator" || value == "tvossimulator" || + value == "watchossimulator" || value == "xrossimulator" || + value == "visionossimulator") { environment = "simulator"; os_name = value.drop_back(environment.size()).str(); - } else if (value.equals("maccatalyst")) { + } else if (value == "maccatalyst") { os_name = "ios"; environment = "macabi"; } else { @@ -1230,44 +1230,44 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) { ByteOrder byte_order = eByteOrderInvalid; uint32_t num_keys_decoded = 0; while (response.GetNameColonValue(name, value)) { - if (name.equals("cputype")) { + if (name == "cputype") { // exception type in big endian hex if (!value.getAsInteger(0, cpu)) ++num_keys_decoded; - } else if (name.equals("cpusubtype")) { + } else if (name == "cpusubtype") { // exception count in big endian hex if (!value.getAsInteger(0, sub)) ++num_keys_decoded; - } else if (name.equals("arch")) { + } else if (name == "arch") { arch_name = std::string(value); ++num_keys_decoded; - } else if (name.equals("triple")) { + } else if (name == "triple") { StringExtractor extractor(value); extractor.GetHexByteString(triple); ++num_keys_decoded; - } else if (name.equals("distribution_id")) { + } else if (name == "distribution_id") { StringExtractor extractor(value); extractor.GetHexByteString(m_host_distribution_id); ++num_keys_decoded; - } else if (name.equals("os_build")) { + } else if (name == "os_build") { StringExtractor extractor(value); extractor.GetHexByteString(m_os_build); ++num_keys_decoded; - } else if (name.equals("hostname")) { + } else if (name == "hostname") { StringExtractor extractor(value); extractor.GetHexByteString(m_hostname); ++num_keys_decoded; - } else if (name.equals("os_kernel")) { + } else if (name == "os_kernel") { StringExtractor extractor(value); extractor.GetHexByteString(m_os_kernel); ++num_keys_decoded; - } else if (name.equals("ostype")) { + } else if (name == "ostype") { ParseOSType(value, os_name, environment); ++num_keys_decoded; - } else if (name.equals("vendor")) { + } else if (name == "vendor") { vendor_name = std::string(value); ++num_keys_decoded; - } else if (name.equals("endian")) { + } else if (name == "endian") { byte_order = llvm::StringSwitch<lldb::ByteOrder>(value) .Case("little", eByteOrderLittle) .Case("big", eByteOrderBig) @@ -1275,30 +1275,30 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) { .Default(eByteOrderInvalid); if (byte_order != eByteOrderInvalid) ++num_keys_decoded; - } else if (name.equals("ptrsize")) { + } else if (name == "ptrsize") { if (!value.getAsInteger(0, pointer_byte_size)) ++num_keys_decoded; - } else if (name.equals("addressing_bits")) { + } else if (name == "addressing_bits") { if (!value.getAsInteger(0, m_low_mem_addressing_bits)) { ++num_keys_decoded; } - } else if (name.equals("high_mem_addressing_bits")) { + } else if (name == "high_mem_addressing_bits") { if (!value.getAsInteger(0, m_high_mem_addressing_bits)) ++num_keys_decoded; - } else if (name.equals("low_mem_addressing_bits")) { + } else if (name == "low_mem_addressing_bits") { if (!value.getAsInteger(0, m_low_mem_addressing_bits)) ++num_keys_decoded; - } else if (name.equals("os_version") || - name.equals("version")) // Older debugserver binaries used - // the "version" key instead of - // "os_version"... + } else if (name == "os_version" || + name == "version") // Older debugserver binaries used + // the "version" key instead of + // "os_version"... { if (!m_os_version.tryParse(value)) ++num_keys_decoded; - } else if (name.equals("maccatalyst_version")) { + } else if (name == "maccatalyst_version") { if (!m_maccatalyst_version.tryParse(value)) ++num_keys_decoded; - } else if (name.equals("watchpoint_exceptions_received")) { + } else if (name == "watchpoint_exceptions_received") { m_watchpoints_trigger_after_instruction = llvm::StringSwitch<LazyBool>(value) .Case("before", eLazyBoolNo) @@ -1306,14 +1306,14 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) { .Default(eLazyBoolCalculate); if (m_watchpoints_trigger_after_instruction != eLazyBoolCalculate) ++num_keys_decoded; - } else if (name.equals("default_packet_timeout")) { + } else if (name == "default_packet_timeout") { uint32_t timeout_seconds; if (!value.getAsInteger(0, timeout_seconds)) { m_default_packet_timeout = seconds(timeout_seconds); SetPacketTimeout(m_default_packet_timeout); ++num_keys_decoded; } - } else if (name.equals("vm-page-size")) { + } else if (name == "vm-page-size") { int page_size; if (!value.getAsInteger(0, page_size)) { m_target_vm_page_size = page_size; @@ -1568,10 +1568,10 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( bool success = true; bool saw_permissions = false; while (success && response.GetNameColonValue(name, value)) { - if (name.equals("start")) { + if (name == "start") { if (!value.getAsInteger(16, addr_value)) region_info.GetRange().SetRangeBase(addr_value); - } else if (name.equals("size")) { + } else if (name == "size") { if (!value.getAsInteger(16, addr_value)) { region_info.GetRange().SetByteSize(addr_value); if (region_info.GetRange().GetRangeEnd() < @@ -1580,8 +1580,7 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( region_info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); } } - } else if (name.equals("permissions") && - region_info.GetRange().IsValid()) { + } else if (name == "permissions" && region_info.GetRange().IsValid()) { saw_permissions = true; if (region_info.GetRange().Contains(addr)) { if (value.contains('r')) @@ -1608,12 +1607,12 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( region_info.SetExecutable(MemoryRegionInfo::eNo); region_info.SetMapped(MemoryRegionInfo::eNo); } - } else if (name.equals("name")) { + } else if (name == "name") { StringExtractorGDBRemote name_extractor(value); std::string name; name_extractor.GetHexByteString(name); region_info.SetName(name.c_str()); - } else if (name.equals("flags")) { + } else if (name == "flags") { region_info.SetMemoryTagged(MemoryRegionInfo::eNo); llvm::StringRef flags = value; @@ -1629,7 +1628,7 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( } } } - } else if (name.equals("type")) { + } else if (name == "type") { std::string comma_sep_str = value.str(); size_t comma_pos; while ((comma_pos = comma_sep_str.find(',')) != std::string::npos) { @@ -1642,13 +1641,13 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( if (comma_sep_str == "stack") { region_info.SetIsStackMemory(MemoryRegionInfo::eYes); } - } else if (name.equals("error")) { + } else if (name == "error") { StringExtractorGDBRemote error_extractor(value); std::string error_string; // Now convert the HEX bytes into a string value error_extractor.GetHexByteString(error_string); error.SetErrorString(error_string.c_str()); - } else if (name.equals("dirty-pages")) { + } else if (name == "dirty-pages") { std::vector<addr_t> dirty_page_list; for (llvm::StringRef x : llvm::split(value, ',')) { addr_t page; @@ -1825,7 +1824,7 @@ std::optional<uint32_t> GDBRemoteCommunicationClient::GetWatchpointSlotCount() { llvm::StringRef name; llvm::StringRef value; while (response.GetNameColonValue(name, value)) { - if (name.equals("num")) { + if (name == "num") { value.getAsInteger(0, m_num_supported_hardware_watchpoints); num = m_num_supported_hardware_watchpoints; } @@ -2006,43 +2005,43 @@ bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse( std::string os_type; while (response.GetNameColonValue(name, value)) { - if (name.equals("pid")) { + if (name == "pid") { lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; value.getAsInteger(0, pid); process_info.SetProcessID(pid); - } else if (name.equals("ppid")) { + } else if (name == "ppid") { lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; value.getAsInteger(0, pid); process_info.SetParentProcessID(pid); - } else if (name.equals("uid")) { + } else if (name == "uid") { uint32_t uid = UINT32_MAX; value.getAsInteger(0, uid); process_info.SetUserID(uid); - } else if (name.equals("euid")) { + } else if (name == "euid") { uint32_t uid = UINT32_MAX; value.getAsInteger(0, uid); process_info.SetEffectiveUserID(uid); - } else if (name.equals("gid")) { + } else if (name == "gid") { uint32_t gid = UINT32_MAX; value.getAsInteger(0, gid); process_info.SetGroupID(gid); - } else if (name.equals("egid")) { + } else if (name == "egid") { uint32_t gid = UINT32_MAX; value.getAsInteger(0, gid); process_info.SetEffectiveGroupID(gid); - } else if (name.equals("triple")) { + } else if (name == "triple") { StringExtractor extractor(value); std::string triple; extractor.GetHexByteString(triple); process_info.GetArchitecture().SetTriple(triple.c_str()); - } else if (name.equals("name")) { + } else if (name == "name") { StringExtractor extractor(value); // The process name from ASCII hex bytes since we can't control the // characters in a process name std::string name; extractor.GetHexByteString(name); process_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); - } else if (name.equals("args")) { + } else if (name == "args") { llvm::StringRef encoded_args(value), hex_arg; bool is_arg0 = true; @@ -2062,13 +2061,13 @@ bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse( process_info.GetArguments().AppendArgument(arg); is_arg0 = false; } - } else if (name.equals("cputype")) { + } else if (name == "cputype") { value.getAsInteger(0, cpu); - } else if (name.equals("cpusubtype")) { + } else if (name == "cpusubtype") { value.getAsInteger(0, sub); - } else if (name.equals("vendor")) { + } else if (name == "vendor") { vendor = std::string(value); - } else if (name.equals("ostype")) { + } else if (name == "ostype") { os_type = std::string(value); } } @@ -2144,10 +2143,10 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) { uint32_t num_keys_decoded = 0; lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; while (response.GetNameColonValue(name, value)) { - if (name.equals("cputype")) { + if (name == "cputype") { if (!value.getAsInteger(16, cpu)) ++num_keys_decoded; - } else if (name.equals("cpusubtype")) { + } else if (name == "cpusubtype") { if (!value.getAsInteger(16, sub)) { ++num_keys_decoded; // Workaround for pre-2024 Apple debugserver, which always @@ -2162,17 +2161,17 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) { sub = 0; } } - } else if (name.equals("triple")) { + } else if (name == "triple") { StringExtractor extractor(value); extractor.GetHexByteString(triple); ++num_keys_decoded; - } else if (name.equals("ostype")) { + } else if (name == "ostype") { ParseOSType(value, os_name, environment); ++num_keys_decoded; - } else if (name.equals("vendor")) { + } else if (name == "vendor") { vendor_name = std::string(value); ++num_keys_decoded; - } else if (name.equals("endian")) { + } else if (name == "endian") { byte_order = llvm::StringSwitch<lldb::ByteOrder>(value) .Case("little", eByteOrderLittle) .Case("big", eByteOrderBig) @@ -2180,19 +2179,19 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) { .Default(eByteOrderInvalid); if (byte_order != eByteOrderInvalid) ++num_keys_decoded; - } else if (name.equals("ptrsize")) { + } else if (name == "ptrsize") { if (!value.getAsInteger(16, pointer_byte_size)) ++num_keys_decoded; - } else if (name.equals("pid")) { + } else if (name == "pid") { if (!value.getAsInteger(16, pid)) ++num_keys_decoded; - } else if (name.equals("elf_abi")) { + } else if (name == "elf_abi") { elf_abi = std::string(value); ++num_keys_decoded; - } else if (name.equals("main-binary-uuid")) { + } else if (name == "main-binary-uuid") { m_process_standalone_uuid.SetFromStringRef(value); ++num_keys_decoded; - } else if (name.equals("main-binary-slide")) { + } else if (name == "main-binary-slide") { StringExtractor extractor(value); m_process_standalone_value = extractor.GetU64(LLDB_INVALID_ADDRESS, 16); @@ -2200,7 +2199,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) { m_process_standalone_value_is_offset = true; ++num_keys_decoded; } - } else if (name.equals("main-binary-address")) { + } else if (name == "main-binary-address") { StringExtractor extractor(value); m_process_standalone_value = extractor.GetU64(LLDB_INVALID_ADDRESS, 16); @@ -2208,7 +2207,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) { m_process_standalone_value_is_offset = false; ++num_keys_decoded; } - } else if (name.equals("binary-addresses")) { + } else if (name == "binary-addresses") { m_binary_addresses.clear(); ++num_keys_decoded; for (llvm::StringRef x : llvm::split(value, ',')) { @@ -2647,9 +2646,9 @@ bool GDBRemoteCommunicationClient::LaunchGDBServer( llvm::StringRef name; llvm::StringRef value; while (response.GetNameColonValue(name, value)) { - if (name.equals("port")) + if (name == "port") value.getAsInteger(0, port); - else if (name.equals("pid")) + else if (name == "pid") value.getAsInteger(0, pid); else if (name.compare("socket_name") == 0) { StringExtractor extractor(value); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index b4fb5b68dd41f..f9d37490e16ae 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -340,13 +340,13 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo( llvm::StringRef value; while (packet.GetNameColonValue(key, value)) { bool success = true; - if (key.equals("name")) { + if (key == "name") { StringExtractor extractor(value); std::string file; extractor.GetHexByteString(file); match_info.GetProcessInfo().GetExecutableFile().SetFile( file, FileSpec::Style::native); - } else if (key.equals("name_match")) { + } else if (key == "name_match") { NameMatch name_match = llvm::StringSwitch<NameMatch>(value) .Case("equals", NameMatch::Equals) .Case("starts_with", NameMatch::StartsWith) @@ -357,40 +357,40 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo( match_info.SetNameMatchType(name_match); if (name_match == NameMatch::Ignore) return SendErrorResponse(2); - } else if (key.equals("pid")) { + } else if (key == "pid") { lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; if (value.getAsInteger(0, pid)) return SendErrorResponse(2); match_info.GetProcessInfo().SetProcessID(pid); - } else if (key.equals("parent_pid")) { + } else if (key == "parent_pid") { lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; if (value.getAsInteger(0, pid)) return SendErrorResponse(2); match_info.GetProcessInfo().SetParentProcessID(pid); - } else if (key.equals("uid")) { + } else if (key == "uid") { uint32_t uid = UINT32_MAX; if (value.getAsInteger(0, uid)) return SendErrorResponse(2); match_info.GetProcessInfo().SetUserID(uid); - } else if (key.equals("gid")) { + } else if (key == "gid") { uint32_t gid = UINT32_MAX; if (value.getAsInteger(0, gid)) return SendErrorResponse(2); match_info.GetProcessInfo().SetGroupID(gid); - } else if (key.equals("euid")) { + } else if (key == "euid") { uint32_t uid = UINT32_MAX; if (value.getAsInteger(0, uid)) return SendErrorResponse(2); match_info.GetProcessInfo().SetEffectiveUserID(uid); - } else if (key.equals("egid")) { + } else if (key == "egid") { uint32_t gid = UINT32_MAX; if (value.getAsInteger(0, gid)) return SendErrorResponse(2); match_info.GetProcessInfo().SetEffectiveGroupID(gid); - } else if (key.equals("all_users")) { + } else if (key == "all_users") { match_info.SetMatchAllUsers( OptionArgParser::ToBoolean(value, false, &success)); - } else if (key.equals("triple")) { + } else if (key == "triple") { match_info.GetProcessInfo().GetArchitecture() = HostInfo::GetAugmentedArchSpec(value); } else { @@ -472,7 +472,7 @@ GDBRemoteCommunicationServerCommon::Handle_qSpeedTest( llvm::StringRef key; llvm::StringRef value; bool success = packet.GetNameColonValue(key, value); - if (success && key.equals("response_size")) { + if (success && key == "response_size") { uint32_t response_size = 0; if (!value.getAsInteger(0, response_size)) { if (response_size == 0) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 391abdae27525..5285ec1d3db4e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -239,9 +239,9 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer( llvm::StringRef value; std::optional<uint16_t> port; while (packet.GetNameColonValue(name, value)) { - if (name.equals("host")) + if (name == "host") hostname = std::string(value); - else if (name.equals("port")) { + else if (name == "port") { // Make the Optional valid so we can use its value port = 0; value.getAsInteger(0, *port); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 871683a605686..a5a731981299f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -448,20 +448,20 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { DynamicRegisterInfo::Register reg_info; while (response.GetNameColonValue(name, value)) { - if (name.equals("name")) { + if (name == "name") { reg_info.name.SetString(value); - } else if (name.equals("alt-name")) { + } else if (name == "alt-name") { reg_info.alt_name.SetString(value); - } else if (name.equals("bitsize")) { + } else if (name == "bitsize") { if (!value.getAsInteger(0, reg_info.byte_size)) reg_info.byte_size /= CHAR_BIT; - } else if (name.equals("offset")) { + } else if (name == "offset") { value.getAsInteger(0, reg_info.byte_offset); - } else if (name.equals("encoding")) { + } else if (name == "encoding") { const Encoding encoding = Args::StringToEncoding(value); if (encoding != eEncodingInvalid) reg_info.encoding = encoding; - } else if (name.equals("format")) { + } else if (name == "format") { if (!OptionArgParser::ToFormat(value.str().c_str(), reg_info.format, nullptr) .Success()) reg_info.format = @@ -480,17 +480,17 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { .Case("vector-uint64", eFormatVectorOfUInt64) .Case("vector-uint128", eFormatVectorOfUInt128) .Default(eFormatInvalid); - } else if (name.equals("set")) { + } else if (name == "set") { reg_info.set_name.SetString(value); - } else if (name.equals("gcc") || name.equals("ehframe")) { + } else if (name == "gcc" || name == "ehframe") { value.getAsInteger(0, reg_info.regnum_ehframe); - } else if (name.equals("dwarf")) { + } else if (name == "dwarf") { value.getAsInteger(0, reg_info.regnum_dwarf); - } else if (name.equals("generic")) { + } else if (name == "generic") { reg_info.regnum_generic = Args::StringToGenericRegister(value); - } else if (name.equals("container-regs")) { + } else if (name == "container-regs") { SplitCommaSeparatedRegisterNumberString(value, reg_info.value_regs, 16); - } else if (name.equals("invalidate-regs")) { + } else if (name == "invalidate-regs") { SplitCommaSeparatedRegisterNumberString(value, reg_info.invalidate_regs, 16); } } @@ -5082,7 +5082,7 @@ std::string ProcessGDBRemote::HarmonizeThreadIdsForProfileData( llvm::StringRef usec_name, usec_value; uint32_t input_file_pos = profileDataExtractor.GetFilePos(); if (profileDataExtractor.GetNameColonValue(usec_name, usec_value)) { - if (usec_name.equals("thread_used_usec")) { + if (usec_name == "thread_used_usec") { has_used_usec = true; usec_value.getAsInteger(0, curr_used_usec); } else { diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index e915bff9e4a47..d656ca3facf73 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -1139,7 +1139,7 @@ PDBASTParser::FindNamespaceDecl(const clang::DeclContext *parent, assert(set); for (clang::NamespaceDecl *namespace_decl : *set) - if (namespace_decl->getName().equals(name)) + if (namespace_decl->getName() == name) return namespace_decl; for (clang::NamespaceDecl *namespace_decl : *set) diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index b26beecc6d126..9a282acae91fb 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1141,8 +1141,8 @@ void SymbolFilePDB::FindGlobalVariables( sc.module_sp = m_objfile_sp->GetModule(); lldbassert(sc.module_sp.get()); - if (!name.GetStringRef().equals( - MSVCUndecoratedNameParser::DropScope(pdb_data->getName()))) + if (name.GetStringRef() != + MSVCUndecoratedNameParser::DropScope(pdb_data->getName())) continue; sc.comp_unit = ParseCompileUnitForUID(GetCompilandId(*pdb_data)).get(); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 17a9c675fbba4..582d9eac3e1dd 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6692,7 +6692,7 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( return child_indexes.size(); child_indexes.pop_back(); - } else if (field_name.equals(name)) { + } else if (field_name == name) { // We have to add on the number of base classes to this index! child_indexes.push_back( child_idx + TypeSystemClang::GetNumBaseClasses( @@ -6779,7 +6779,7 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { const clang::ObjCIvarDecl *ivar_decl = *ivar_pos; - if (ivar_decl->getName().equals(name_sref)) { + if (ivar_decl->getName() == name_sref) { if ((!omit_empty_base_classes && superclass_interface_decl) || (omit_empty_base_classes && ObjCDeclHasIVars(superclass_interface_decl, true))) @@ -6948,7 +6948,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++child_idx) { - if (field->getName().equals(name)) + if (field->getName() == name) return child_idx; } } @@ -6975,7 +6975,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { const clang::ObjCIvarDecl *ivar_decl = *ivar_pos; - if (ivar_decl->getName().equals(name)) { + if (ivar_decl->getName() == name) { if ((!omit_empty_base_classes && superclass_interface_decl) || (omit_empty_base_classes && ObjCDeclHasIVars(superclass_interface_decl, true))) @@ -6986,7 +6986,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, } if (superclass_interface_decl) { - if (superclass_interface_decl->getName().equals(name)) + if (superclass_interface_decl->getName() == name) return 0; } } @@ -9231,15 +9231,14 @@ std::vector<CompilerDecl> TypeSystemClang::DeclContextFindDeclByName( if (clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target)) { IdentifierInfo *ii = nd->getIdentifier(); - if (ii != nullptr && - ii->getName().equals(name.AsCString(nullptr))) + if (ii != nullptr && ii->getName() == name.AsCString(nullptr)) found_decls.push_back(GetCompilerDecl(nd)); } } } else if (clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(child)) { IdentifierInfo *ii = nd->getIdentifier(); - if (ii != nullptr && ii->getName().equals(name.AsCString(nullptr))) + if (ii != nullptr && ii->getName() == name.AsCString(nullptr)) found_decls.push_back(GetCompilerDecl(nd)); } } @@ -9349,7 +9348,7 @@ uint32_t TypeSystemClang::CountDeclLevels(clang::DeclContext *frame_decl_ctx, // Check names. IdentifierInfo *ii = nd->getIdentifier(); if (ii == nullptr || - !ii->getName().equals(child_name->AsCString(nullptr))) + ii->getName() != child_name->AsCString(nullptr)) continue; // Check types, if one was provided. if (child_type) { diff --git a/lldb/source/Target/PathMappingList.cpp b/lldb/source/Target/PathMappingList.cpp index c369018122a59..9c283b0146fe0 100644 --- a/lldb/source/Target/PathMappingList.cpp +++ b/lldb/source/Target/PathMappingList.cpp @@ -86,8 +86,8 @@ bool PathMappingList::AppendUnique(llvm::StringRef path, auto normalized_replacement = NormalizePath(replacement); std::lock_guard<std::recursive_mutex> lock(m_mutex); for (const auto &pair : m_pairs) { - if (pair.first.GetStringRef().equals(normalized_path) && - pair.second.GetStringRef().equals(normalized_replacement)) + if (pair.first.GetStringRef() == normalized_path && + pair.second.GetStringRef() == normalized_replacement) return false; } Append(path, replacement, notify); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits