Skip to content

[lldb] Use operator==(StringRef, StringRef) instead of StringRef::equals (NFC) #92476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 17 additions & 17 deletions lldb/source/Expression/IRExecutionUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()) {
Expand All @@ -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());
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Language/ObjC/Cocoa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Loading
Loading