Skip to content

Commit d72f5b1

Browse files
committed
Update StringRef::equals references to operator==
`equals` has been deprecated upstream, use `operator==` instead.
1 parent 11696cd commit d72f5b1

35 files changed

+93
-95
lines changed

include/swift/AST/Attr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2875,7 +2875,7 @@ class DeclAttributes {
28752875
/// Return whether this attribute set includes the given semantics attribute.
28762876
bool hasSemanticsAttr(StringRef attrValue) const {
28772877
return llvm::any_of(getSemanticsAttrs(), [&](const SemanticsAttr *attr) {
2878-
return attrValue.equals(attr->Value);
2878+
return attrValue == attr->Value;
28792879
});
28802880
}
28812881

include/swift/AST/Decl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6590,7 +6590,7 @@ class VarDecl : public AbstractStorageDecl {
65906590
/// attribute.
65916591
bool hasSemanticsAttr(StringRef attrValue) const {
65926592
return llvm::any_of(getSemanticsAttrs(), [&](const SemanticsAttr *attr) {
6593-
return attrValue.equals(attr->Value);
6593+
return attrValue == attr->Value;
65946594
});
65956595
}
65966596

include/swift/AST/Identifier.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Identifier {
9696
bool nonempty() const { return !empty(); }
9797

9898
LLVM_ATTRIBUTE_USED bool is(StringRef string) const {
99-
return str().equals(string);
99+
return str() == string;
100100
}
101101

102102
/// isOperator - Return true if this identifier is an operator, false if it is

include/swift/Basic/JSONSerialization.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ inline bool isNumeric(llvm::StringRef S) {
355355
return false;
356356
}
357357

358-
inline bool isNull(llvm::StringRef S) { return S.equals("null"); }
358+
inline bool isNull(llvm::StringRef S) { return S == "null"; }
359359

360360
inline bool isBool(llvm::StringRef S) {
361-
return S.equals("true") || S.equals("false");
361+
return S == "true" || S == "false";
362362
}
363363

364364
template<typename T>

include/swift/Frontend/InputFile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class InputFile final {
9595
/// llvm::MemoryBuffer::getFileOrSTDIN, which uses "<stdin>" instead of "-".
9696
static StringRef convertBufferNameFromLLVM_getFileOrSTDIN_toSwiftConventions(
9797
StringRef filename) {
98-
return filename.equals("<stdin>") ? "-" : filename;
98+
return filename == "<stdin>" ? "-" : filename;
9999
}
100100

101101
/// Retrieves the name of the output file corresponding to this input.

include/swift/SIL/SILLocation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class SILLocation {
7171

7272
inline bool operator==(const FilenameAndLocation &rhs) const {
7373
return line == rhs.line && column == rhs.column &&
74-
filename.equals(rhs.filename);
74+
filename == rhs.filename;
7575
}
7676

7777
void dump() const;

include/swift/SILOptimizer/PassManager/PassPipeline.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct SILPassPipeline final {
4242

4343
friend bool operator==(const SILPassPipeline &lhs,
4444
const SILPassPipeline &rhs) {
45-
return lhs.ID == rhs.ID && lhs.Name.equals(rhs.Name) &&
45+
return lhs.ID == rhs.ID && lhs.Name == rhs.Name &&
4646
lhs.KindOffset == rhs.KindOffset;
4747
}
4848

lib/ClangImporter/ImportDecl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5306,8 +5306,8 @@ namespace {
53065306

53075307
// Add inferred attributes.
53085308
#define INFERRED_ATTRIBUTES(ModuleName, ClassName, AttributeSet) \
5309-
if (name.str().equals(#ClassName) && \
5310-
result->getParentModule()->getName().str().equals(#ModuleName)) { \
5309+
if (name.str() == #ClassName && \
5310+
result->getParentModule()->getName().str() == #ModuleName) { \
53115311
using namespace inferred_attributes; \
53125312
addInferredAttributes(result, AttributeSet); \
53135313
}

lib/Driver/DarwinToolChains.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,19 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
379379
if (context.Args.hasArg(options::OPT_runtime_compatibility_version)) {
380380
auto value = context.Args.getLastArgValue(
381381
options::OPT_runtime_compatibility_version);
382-
if (value.equals("5.0")) {
382+
if (value == "5.0") {
383383
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
384-
} else if (value.equals("5.1")) {
384+
} else if (value == "5.1") {
385385
runtimeCompatibilityVersion = llvm::VersionTuple(5, 1);
386-
} else if (value.equals("5.5")) {
386+
} else if (value == "5.5") {
387387
runtimeCompatibilityVersion = llvm::VersionTuple(5, 5);
388-
} else if (value.equals("5.6")) {
388+
} else if (value == "5.6") {
389389
runtimeCompatibilityVersion = llvm::VersionTuple(5, 6);
390-
} else if (value.equals("5.8")) {
390+
} else if (value == "5.8") {
391391
runtimeCompatibilityVersion = llvm::VersionTuple(5, 8);
392-
} else if (value.equals("6.0")) {
392+
} else if (value == "6.0") {
393393
runtimeCompatibilityVersion = llvm::VersionTuple(6, 0);
394-
} else if (value.equals("none")) {
394+
} else if (value == "none") {
395395
runtimeCompatibilityVersion = std::nullopt;
396396
} else {
397397
// TODO: diagnose unknown runtime compatibility version?

lib/Driver/Driver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ void Driver::buildInputs(const ToolChain &TC,
936936
file_types::ID Ty = file_types::TY_INVALID;
937937

938938
// stdin must be handled specially.
939-
if (Value.equals("-")) {
939+
if (Value == "-") {
940940
// By default, treat stdin as Swift input.
941941
Ty = file_types::TY_Swift;
942942
} else {

lib/DriverTool/swift_cache_tool_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class SwiftCacheToolInvocation {
189189
// command-line.
190190
if (StringRef(FrontendArgs[0]).ends_with("swift-frontend"))
191191
FrontendArgs.erase(FrontendArgs.begin());
192-
if (StringRef(FrontendArgs[0]).equals("-frontend"))
192+
if (StringRef(FrontendArgs[0]) == "-frontend")
193193
FrontendArgs.erase(FrontendArgs.begin());
194194

195195
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4>

lib/Frontend/CompilerInvocation.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -2741,9 +2741,9 @@ void CompilerInvocation::buildDebugFlags(std::string &Output,
27412741
for (auto A : ReducedArgs) {
27422742
StringRef Arg(A);
27432743
// FIXME: this should distinguish between key and value.
2744-
if (!haveSDKPath && Arg.equals("-sdk"))
2744+
if (!haveSDKPath && Arg == "-sdk")
27452745
haveSDKPath = true;
2746-
if (!haveResourceDir && Arg.equals("-resource-dir"))
2746+
if (!haveResourceDir && Arg == "-resource-dir")
27472747
haveResourceDir = true;
27482748
}
27492749
if (!haveSDKPath) {
@@ -3148,19 +3148,19 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
31483148
if (auto versionArg = Args.getLastArg(
31493149
options::OPT_runtime_compatibility_version)) {
31503150
auto version = StringRef(versionArg->getValue());
3151-
if (version.equals("none")) {
3151+
if (version == "none") {
31523152
runtimeCompatibilityVersion = std::nullopt;
3153-
} else if (version.equals("5.0")) {
3153+
} else if (version == "5.0") {
31543154
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
3155-
} else if (version.equals("5.1")) {
3155+
} else if (version == "5.1") {
31563156
runtimeCompatibilityVersion = llvm::VersionTuple(5, 1);
3157-
} else if (version.equals("5.5")) {
3157+
} else if (version == "5.5") {
31583158
runtimeCompatibilityVersion = llvm::VersionTuple(5, 5);
3159-
} else if (version.equals("5.6")) {
3159+
} else if (version == "5.6") {
31603160
runtimeCompatibilityVersion = llvm::VersionTuple(5, 6);
3161-
} else if (version.equals("5.8")) {
3161+
} else if (version == "5.8") {
31623162
runtimeCompatibilityVersion = llvm::VersionTuple(5, 8);
3163-
} else if (version.equals("6.0")) {
3163+
} else if (version == "6.0") {
31643164
runtimeCompatibilityVersion = llvm::VersionTuple(6, 0);
31653165
} else {
31663166
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,

lib/Frontend/DependencyVerifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ struct Obligation {
192192
}
193193
static bool isEqual(const Obligation::Key &LHS,
194194
const Obligation::Key &RHS) {
195-
return LHS.Name.equals(RHS.Name) && LHS.Kind == RHS.Kind;
195+
return LHS.Name == RHS.Name && LHS.Kind == RHS.Kind;
196196
}
197197
};
198198
};

lib/Frontend/DiagnosticVerifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ DiagnosticVerifier::Result DiagnosticVerifier::verifyFile(unsigned BufferID) {
10331033
// Verify educational notes
10341034
for (auto &foundName : FoundDiagnostic.EducationalNotes) {
10351035
llvm::erase_if(expectedNotes->Names,
1036-
[&](StringRef item) { return item.equals(foundName); });
1036+
[&](StringRef item) { return item == foundName; });
10371037
}
10381038

10391039
if (!expectedNotes->Names.empty()) {

lib/IDE/Formatting.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ class FormatWalker : public ASTWalker {
12701270
getLocForContentStartOnSameLine(SM, StringLiteralRange.getEnd());
12711271
bool HaveEndQuotes = CharSourceRange(SM, EndLineContentLoc,
12721272
StringLiteralRange.getEnd())
1273-
.str().equals(StringRef("\"\"\""));
1273+
.str() == "\"\"\"";
12741274

12751275
if (!HaveEndQuotes) {
12761276
// Indent to the same indentation level as the first non-empty line

lib/IRGen/GenHeap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ llvm::Constant *IRGenModule::getFixLifetimeFn() {
12771277
llvm::GlobalValue::PrivateLinkage,
12781278
"__swift_fixLifetime",
12791279
&Module);
1280-
assert(fixLifetime->getName().equals("__swift_fixLifetime")
1280+
assert(fixLifetime->getName() == "__swift_fixLifetime"
12811281
&& "fixLifetime symbol name got mangled?!");
12821282
// Don't inline the function, so it stays as a signal to the ARC passes.
12831283
// The ARC passes will remove references to the function when they're

lib/IRGen/IRGenModule.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ static bool replaceModuleFlagsEntry(llvm::LLVMContext &Ctx,
16271627
llvm::MDNode *Op = ModuleFlags->getOperand(I);
16281628
llvm::MDString *ID = cast<llvm::MDString>(Op->getOperand(1));
16291629

1630-
if (ID->getString().equals(EntryName)) {
1630+
if (ID->getString() == EntryName) {
16311631

16321632
// Create the new entry.
16331633
llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx);

lib/IRGen/IRGenSIL.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ class IRGenSILFunction :
853853
auto *callee = call->getCalledFunction();
854854
if (!callee)
855855
return false;
856-
auto isTaskAlloc = callee->getName().equals("swift_task_alloc");
856+
auto isTaskAlloc = callee->getName() == "swift_task_alloc";
857857
return isTaskAlloc;
858858
}
859859

@@ -2966,31 +2966,31 @@ FunctionPointer::Kind irgen::classifyFunctionPointerKind(SILFunction *fn) {
29662966
// Check for some special cases, which are currently all async:
29672967
if (fn->isAsync()) {
29682968
auto name = fn->getName();
2969-
if (name.equals("swift_task_future_wait"))
2969+
if (name == "swift_task_future_wait")
29702970
return SpecialKind::TaskFutureWait;
2971-
if (name.equals("swift_task_future_wait_throwing"))
2971+
if (name == "swift_task_future_wait_throwing")
29722972
return SpecialKind::TaskFutureWaitThrowing;
29732973

2974-
if (name.equals("swift_asyncLet_wait"))
2974+
if (name == "swift_asyncLet_wait")
29752975
return SpecialKind::AsyncLetWait;
2976-
if (name.equals("swift_asyncLet_wait_throwing"))
2976+
if (name == "swift_asyncLet_wait_throwing")
29772977
return SpecialKind::AsyncLetWaitThrowing;
29782978

2979-
if (name.equals("swift_asyncLet_get"))
2979+
if (name == "swift_asyncLet_get")
29802980
return SpecialKind::AsyncLetGet;
2981-
if (name.equals("swift_asyncLet_get_throwing"))
2981+
if (name == "swift_asyncLet_get_throwing")
29822982
return SpecialKind::AsyncLetGetThrowing;
29832983

2984-
if (name.equals("swift_asyncLet_finish"))
2984+
if (name == "swift_asyncLet_finish")
29852985
return SpecialKind::AsyncLetFinish;
2986-
2987-
if (name.equals("swift_taskGroup_wait_next_throwing"))
2986+
2987+
if (name == "swift_taskGroup_wait_next_throwing")
29882988
return SpecialKind::TaskGroupWaitNext;
29892989

2990-
if (name.equals("swift_taskGroup_waitAll"))
2990+
if (name == "swift_taskGroup_waitAll")
29912991
return SpecialKind::TaskGroupWaitAll;
29922992

2993-
if (name.equals("swift_distributed_execute_target"))
2993+
if (name == "swift_distributed_execute_target")
29942994
return SpecialKind::DistributedExecuteTarget;
29952995
}
29962996

lib/Parse/ParseDecl.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -5377,7 +5377,7 @@ ParserStatus Parser::parseDeclModifierList(DeclAttributes &Attributes,
53775377
// or witness something static.
53785378
if (isStartOfSwiftDecl() || (isa<ClassDecl>(CurDeclContext) &&
53795379
(Tok.is(tok::code_complete) ||
5380-
Tok.getRawText().equals("override")))) {
5380+
Tok.getRawText() == "override"))) {
53815381
/* We're OK */
53825382
} else {
53835383
// This 'class' is a real ClassDecl introducer.
@@ -5536,13 +5536,13 @@ ParserStatus Parser::ParsedTypeAttributeList::slowParse(Parser &P) {
55365536
if (Tok.is(tok::kw_inout)) {
55375537
Specifier = ParamDecl::Specifier::InOut;
55385538
} else if (Tok.is(tok::identifier)) {
5539-
if (Tok.getRawText().equals("__shared")) {
5539+
if (Tok.getRawText() == "__shared") {
55405540
Specifier = ParamDecl::Specifier::LegacyShared;
5541-
} else if (Tok.getRawText().equals("__owned")) {
5541+
} else if (Tok.getRawText() == "__owned") {
55425542
Specifier = ParamDecl::Specifier::LegacyOwned;
5543-
} else if (Tok.getRawText().equals("borrowing")) {
5543+
} else if (Tok.getRawText() == "borrowing") {
55445544
Specifier = ParamDecl::Specifier::Borrowing;
5545-
} else if (Tok.getRawText().equals("consuming")) {
5545+
} else if (Tok.getRawText() == "consuming") {
55465546
Specifier = ParamDecl::Specifier::Consuming;
55475547
}
55485548
}
@@ -5859,7 +5859,7 @@ bool Parser::isStartOfSwiftDecl(bool allowPoundIfAttributes,
58595859
// The protocol keyword needs more checking to reject "protocol<Int>".
58605860
if (Tok.is(tok::kw_protocol)) {
58615861
const Token &Tok2 = peekToken();
5862-
return !Tok2.isAnyOperator() || !Tok2.getText().equals("<");
5862+
return !Tok2.isAnyOperator() || Tok2.getText() != "<";
58635863
}
58645864

58655865
// The 'try' case is only for simple local recovery, so we only bother to
@@ -10139,7 +10139,7 @@ Parser::parseDeclOperator(ParseDeclOptions Flags, DeclAttributes &Attributes) {
1013910139

1014010140
const auto maybeDiagnoseInvalidCharInOperatorName = [this](const Token &Tk) {
1014110141
if (Tk.is(tok::identifier)) {
10142-
if (Tk.getText().equals("$") ||
10142+
if (Tk.getText() == "$" ||
1014310143
!DeclAttribute::getAttrKindFromString(Tk.getText())) {
1014410144
diagnose(Tk, diag::identifier_within_operator_name, Tk.getText());
1014510145
return true;

lib/Parse/ParseExpr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
17271727
// If we have a generic argument list, this is something like
17281728
// "case let E<Int>.e(y)", and 'E' should be parsed as a normal name, not
17291729
// a binding.
1730-
if (peekToken().isAnyOperator() && peekToken().getText().equals("<")) {
1730+
if (peekToken().isAnyOperator() && peekToken().getText() == "<") {
17311731
BacktrackingScope S(*this);
17321732
consumeToken();
17331733
return !canParseAsGenericArgumentList();

lib/Parse/ParsePattern.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ ParserResult<Pattern> Parser::parseMatchingPattern(bool isExprBasic) {
14121412
// binding, which isn't yet supported.
14131413
if (peekToken().isAny(tok::period, tok::period_prefix, tok::l_paren,
14141414
tok::l_square)
1415-
|| (peekToken().isAnyOperator() && peekToken().getText().equals("<"))) {
1415+
|| (peekToken().isAnyOperator() && peekToken().getText() == "<")) {
14161416

14171417
// Diagnose the unsupported production.
14181418
diagnose(Tok.getLoc(),

lib/Parse/ParseType.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID, ParseTypeReason reason) {
10041004
.fixItInsert(FirstTypeLoc, keyword.str() + " ");
10051005
}
10061006

1007-
const bool isAnyKeyword = keyword.equals("any");
1007+
const bool isAnyKeyword = keyword == "any";
10081008

10091009
if (isAnyKeyword) {
10101010
if (anyLoc.isInvalid()) {
@@ -1508,7 +1508,7 @@ static bool isGenericTypeDisambiguatingToken(Parser &P) {
15081508
}
15091509

15101510
bool Parser::canParseAsGenericArgumentList() {
1511-
if (!Tok.isAnyOperator() || !Tok.getText().equals("<"))
1511+
if (!Tok.isAnyOperator() || Tok.getText() != "<")
15121512
return false;
15131513

15141514
BacktrackingScope backtrack(*this);

lib/SIL/IR/SILInstruction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ namespace {
538538
bool visitStringLiteralInst(const StringLiteralInst *RHS) {
539539
auto LHS_ = cast<StringLiteralInst>(LHS);
540540
return LHS_->getEncoding() == RHS->getEncoding()
541-
&& LHS_->getValue().equals(RHS->getValue());
541+
&& LHS_->getValue() == RHS->getValue();
542542
}
543543

544544
bool visitStructInst(const StructInst *RHS) {

0 commit comments

Comments
 (0)