Skip to content

Commit c339226

Browse files
[lldb] Use operator==(StringRef, StringRef) instead of StringRef::equals (NFC) (llvm#92476)
Note that StringRef::equals has been deprecated in favor of operator==(StringRef, StringRef).
1 parent 9f15aa0 commit c339226

File tree

14 files changed

+136
-138
lines changed

14 files changed

+136
-138
lines changed

lldb/source/Commands/CommandObjectThread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads {
151151

152152
for (size_t idx = 0; idx < num_entries; idx++) {
153153
llvm::StringRef arg_string = copy_args[idx].ref();
154-
if (arg_string.equals("-c") || count_opt.starts_with(arg_string)) {
154+
if (arg_string == "-c" || count_opt.starts_with(arg_string)) {
155155
idx++;
156156
if (idx == num_entries)
157157
return std::nullopt;
158158
count_idx = idx;
159159
if (copy_args[idx].ref().getAsInteger(0, count_val))
160160
return std::nullopt;
161-
} else if (arg_string.equals("-s") || start_opt.starts_with(arg_string)) {
161+
} else if (arg_string == "-s" || start_opt.starts_with(arg_string)) {
162162
idx++;
163163
if (idx == num_entries)
164164
return std::nullopt;

lldb/source/Core/FormatEntity.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ static Status ParseEntry(const llvm::StringRef &format_str,
19211921
const size_t n = parent->num_children;
19221922
for (size_t i = 0; i < n; ++i) {
19231923
const Definition *entry_def = parent->children + i;
1924-
if (key.equals(entry_def->name) || entry_def->name[0] == '*') {
1924+
if (key == entry_def->name || entry_def->name[0] == '*') {
19251925
llvm::StringRef value;
19261926
if (sep_char)
19271927
value =
@@ -2002,7 +2002,7 @@ static const Definition *FindEntry(const llvm::StringRef &format_str,
20022002
const size_t n = parent->num_children;
20032003
for (size_t i = 0; i < n; ++i) {
20042004
const Definition *entry_def = parent->children + i;
2005-
if (p.first.equals(entry_def->name) || entry_def->name[0] == '*') {
2005+
if (p.first == entry_def->name || entry_def->name[0] == '*') {
20062006
if (p.second.empty()) {
20072007
if (format_str.back() == '.')
20082008
remainder = format_str.drop_front(format_str.size() - 1);
@@ -2351,13 +2351,13 @@ Status FormatEntity::ExtractVariableInfo(llvm::StringRef &format_str,
23512351
bool FormatEntity::FormatFileSpec(const FileSpec &file_spec, Stream &s,
23522352
llvm::StringRef variable_name,
23532353
llvm::StringRef variable_format) {
2354-
if (variable_name.empty() || variable_name.equals(".fullpath")) {
2354+
if (variable_name.empty() || variable_name == ".fullpath") {
23552355
file_spec.Dump(s.AsRawOstream());
23562356
return true;
2357-
} else if (variable_name.equals(".basename")) {
2357+
} else if (variable_name == ".basename") {
23582358
s.PutCString(file_spec.GetFilename().GetStringRef());
23592359
return true;
2360-
} else if (variable_name.equals(".dirname")) {
2360+
} else if (variable_name == ".dirname") {
23612361
s.PutCString(file_spec.GetFilename().GetStringRef());
23622362
return true;
23632363
}
@@ -2440,7 +2440,7 @@ void FormatEntity::AutoComplete(CompletionRequest &request) {
24402440
// "${thread.id" <TAB>
24412441
request.AddCompletion(MakeMatch(str, "}"));
24422442
}
2443-
} else if (remainder.equals(".")) {
2443+
} else if (remainder == ".") {
24442444
// "${thread." <TAB>
24452445
StringList new_matches;
24462446
AddMatches(entry_def, str, llvm::StringRef(), new_matches);

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -534,63 +534,63 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName(
534534
}
535535

536536
if (!name.empty()) {
537-
if (name.equals("__text") || name.equals(".text"))
537+
if (name == "__text" || name == ".text")
538538
sect_type = lldb::eSectionTypeCode;
539-
else if (name.equals("__data") || name.equals(".data"))
539+
else if (name == "__data" || name == ".data")
540540
sect_type = lldb::eSectionTypeCode;
541541
else if (name.starts_with("__debug_") || name.starts_with(".debug_")) {
542542
const uint32_t name_idx = name[0] == '_' ? 8 : 7;
543543
llvm::StringRef dwarf_name(name.substr(name_idx));
544544
switch (dwarf_name[0]) {
545545
case 'a':
546-
if (dwarf_name.equals("abbrev"))
546+
if (dwarf_name == "abbrev")
547547
sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
548-
else if (dwarf_name.equals("aranges"))
548+
else if (dwarf_name == "aranges")
549549
sect_type = lldb::eSectionTypeDWARFDebugAranges;
550-
else if (dwarf_name.equals("addr"))
550+
else if (dwarf_name == "addr")
551551
sect_type = lldb::eSectionTypeDWARFDebugAddr;
552552
break;
553553

554554
case 'f':
555-
if (dwarf_name.equals("frame"))
555+
if (dwarf_name == "frame")
556556
sect_type = lldb::eSectionTypeDWARFDebugFrame;
557557
break;
558558

559559
case 'i':
560-
if (dwarf_name.equals("info"))
560+
if (dwarf_name == "info")
561561
sect_type = lldb::eSectionTypeDWARFDebugInfo;
562562
break;
563563

564564
case 'l':
565-
if (dwarf_name.equals("line"))
565+
if (dwarf_name == "line")
566566
sect_type = lldb::eSectionTypeDWARFDebugLine;
567-
else if (dwarf_name.equals("loc"))
567+
else if (dwarf_name == "loc")
568568
sect_type = lldb::eSectionTypeDWARFDebugLoc;
569-
else if (dwarf_name.equals("loclists"))
569+
else if (dwarf_name == "loclists")
570570
sect_type = lldb::eSectionTypeDWARFDebugLocLists;
571571
break;
572572

573573
case 'm':
574-
if (dwarf_name.equals("macinfo"))
574+
if (dwarf_name == "macinfo")
575575
sect_type = lldb::eSectionTypeDWARFDebugMacInfo;
576576
break;
577577

578578
case 'p':
579-
if (dwarf_name.equals("pubnames"))
579+
if (dwarf_name == "pubnames")
580580
sect_type = lldb::eSectionTypeDWARFDebugPubNames;
581-
else if (dwarf_name.equals("pubtypes"))
581+
else if (dwarf_name == "pubtypes")
582582
sect_type = lldb::eSectionTypeDWARFDebugPubTypes;
583583
break;
584584

585585
case 's':
586-
if (dwarf_name.equals("str"))
586+
if (dwarf_name == "str")
587587
sect_type = lldb::eSectionTypeDWARFDebugStr;
588-
else if (dwarf_name.equals("str_offsets"))
588+
else if (dwarf_name == "str_offsets")
589589
sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
590590
break;
591591

592592
case 'r':
593-
if (dwarf_name.equals("ranges"))
593+
if (dwarf_name == "ranges")
594594
sect_type = lldb::eSectionTypeDWARFDebugRanges;
595595
break;
596596

@@ -599,7 +599,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName(
599599
}
600600
} else if (name.starts_with("__apple_") || name.starts_with(".apple_"))
601601
sect_type = lldb::eSectionTypeInvalid;
602-
else if (name.equals("__objc_imageinfo"))
602+
else if (name == "__objc_imageinfo")
603603
sect_type = lldb::eSectionTypeOther;
604604
}
605605
return sect_type;

lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
14491449

14501450
Argument *argument = &*iter;
14511451

1452-
if (argument->getName().equals("this")) {
1452+
if (argument->getName() == "this") {
14531453
++iter;
14541454

14551455
if (iter == llvm_function.arg_end()) {
@@ -1461,7 +1461,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
14611461
}
14621462

14631463
argument = &*iter;
1464-
} else if (argument->getName().equals("self")) {
1464+
} else if (argument->getName() == "self") {
14651465
++iter;
14661466

14671467
if (iter == llvm_function.arg_end()) {
@@ -1472,7 +1472,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
14721472
return false;
14731473
}
14741474

1475-
if (!iter->getName().equals("_cmd")) {
1475+
if (iter->getName() != "_cmd") {
14761476
m_error_stream.Format("Internal error [IRForTarget]: Wrapper takes '{0}' "
14771477
"after 'self' argument (should take '_cmd')",
14781478
iter->getName());
@@ -1493,7 +1493,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
14931493
argument = &*iter;
14941494
}
14951495

1496-
if (!argument->getName().equals("$__lldb_arg")) {
1496+
if (argument->getName() != "$__lldb_arg") {
14971497
m_error_stream.Format("Internal error [IRForTarget]: Wrapper takes an "
14981498
"argument named '{0}' instead of the struct pointer",
14991499
argument->getName());

lldb/source/Plugins/Language/ObjC/Cocoa.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ bool lldb_private::formatters::NSURLSummaryProvider(
802802

803803
llvm::StringRef class_name = descriptor->GetClassName().GetStringRef();
804804

805-
if (!class_name.equals("NSURL"))
805+
if (class_name != "NSURL")
806806
return false;
807807

808808
uint64_t offset_text = ptr_size + ptr_size +

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,7 @@ ObjectFile::Strata ObjectFileELF::CalculateStrata() {
35573557
// decrease by one
35583558
llvm::StringRef loader_name(buffer, read_size - 1);
35593559
llvm::StringRef freebsd_kernel_loader_name("/red/herring");
3560-
if (loader_name.equals(freebsd_kernel_loader_name))
3560+
if (loader_name == freebsd_kernel_loader_name)
35613561
return eStrataKernel;
35623562
}
35633563
}

0 commit comments

Comments
 (0)