diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h index a5b9eec50c825..be3193c6ef9be 100644 --- a/llvm/include/llvm/ADT/SmallString.h +++ b/llvm/include/llvm/ADT/SmallString.h @@ -89,7 +89,7 @@ class SmallString : public SmallVector { /// Check for string equality. This is more efficient than compare() when /// the relative ordering of inequal strings isn't needed. - [[nodiscard]] bool equals(StringRef RHS) const { return str().equals(RHS); } + [[nodiscard]] bool equals(StringRef RHS) const { return str() == RHS; } /// Check for string equality, ignoring case. [[nodiscard]] bool equals_insensitive(StringRef RHS) const { diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 73fe63b5b8f6f..be2381cd7d779 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -6896,7 +6896,7 @@ Error BitcodeReader::materialize(GlobalValue *GV) { MDString *MDS = cast(MD->getOperand(0)); StringRef ProfName = MDS->getString(); // Check consistency of !prof branch_weights metadata. - if (!ProfName.equals("branch_weights")) + if (ProfName != "branch_weights") continue; unsigned ExpectedNumOperands = 0; if (BranchInst *BI = dyn_cast(&I)) diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index edeb563076fdc..eaf8c35142def 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -659,7 +659,7 @@ void RuntimeDyldELF::setMipsABI(const ObjectFile &Obj) { IsMipsO32ABI = AbiVariant & ELF::EF_MIPS_ABI_O32; IsMipsN32ABI = AbiVariant & ELF::EF_MIPS_ABI2; } - IsMipsN64ABI = Obj.getFileFormatName().equals("elf64-mips"); + IsMipsN64ABI = Obj.getFileFormatName() == "elf64-mips"; } // Return the .TOC. section and offset. diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 8f80a69c4abd3..1719f8ef2b436 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -374,7 +374,7 @@ Expected Pattern::parseNumericVariableDefinition( Expected> Pattern::parseNumericVariableUse( StringRef Name, bool IsPseudo, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { - if (IsPseudo && !Name.equals("@LINE")) + if (IsPseudo && Name != "@LINE") return ErrorDiagnostic::get( SM, Name, "invalid pseudo numeric variable '" + Name + "'"); diff --git a/llvm/lib/FuzzMutate/FuzzerCLI.cpp b/llvm/lib/FuzzMutate/FuzzerCLI.cpp index 58e4b74f4b228..504532865440f 100644 --- a/llvm/lib/FuzzMutate/FuzzerCLI.cpp +++ b/llvm/lib/FuzzMutate/FuzzerCLI.cpp @@ -21,7 +21,7 @@ void llvm::parseFuzzerCLOpts(int ArgC, char *ArgV[]) { int I = 1; while (I < ArgC) - if (StringRef(ArgV[I++]).equals("-ignore_remaining_args=1")) + if (StringRef(ArgV[I++]) == "-ignore_remaining_args=1") break; while (I < ArgC) CLArgs.push_back(ArgV[I++]); @@ -39,7 +39,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) { SmallVector Opts; NameAndArgs.second.split(Opts, '-'); for (StringRef Opt : Opts) { - if (Opt.equals("gisel")) { + if (Opt == "gisel") { Args.push_back("-global-isel"); // For now we default GlobalISel to -O0 Args.push_back("-O0"); @@ -151,7 +151,7 @@ int llvm::runFuzzerOnInputs(int ArgC, char *ArgV[], FuzzerTestFun TestOne, for (int I = 1; I < ArgC; ++I) { StringRef Arg(ArgV[I]); if (Arg.starts_with("-")) { - if (Arg.equals("-ignore_remaining_args=1")) + if (Arg == "-ignore_remaining_args=1") break; continue; } diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp index f839fe944e18f..eac78069f4d2b 100644 --- a/llvm/lib/LTO/LTOModule.cpp +++ b/llvm/lib/LTO/LTOModule.cpp @@ -694,7 +694,7 @@ bool LTOModule::hasCtorDtor() const { if (auto *GV = dyn_cast_if_present(Sym)) { StringRef Name = GV->getName(); if (Name.consume_front("llvm.global_")) { - if (Name.equals("ctors") || Name.equals("dtors")) + if (Name == "ctors" || Name == "dtors") return true; } } diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 3dc70a4015892..f257d0d9e83f7 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -468,7 +468,7 @@ void MCAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) { void MCAsmStreamer::addExplicitComment(const Twine &T) { StringRef c = T.getSingleStringRef(); - if (c.equals(StringRef(MAI->getSeparatorString()))) + if (c == MAI->getSeparatorString()) return; if (c.starts_with(StringRef("//"))) { ExplicitCommentToEmit.append("\t"); diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 76a3e501f4590..8d9acd54e8797 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -4543,7 +4543,7 @@ bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) { // Emit an error if two (or more) named parameters share the same name for (const MCAsmMacroParameter& CurrParam : Parameters) - if (CurrParam.Name.equals(Parameter.Name)) + if (CurrParam.Name == Parameter.Name) return TokError("macro '" + Name + "' has multiple parameters" " named '" + Parameter.Name + "'"); diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp index 3cd44e7195be6..a97b72997ae39 100644 --- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp @@ -705,7 +705,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) { .Case("__datacoal_nt", "__data") .Default(Section); - if (!Section.equals(NonCoalSection)) { + if (Section != NonCoalSection) { StringRef SectionVal(Loc.getPointer()); size_t B = SectionVal.find(',') + 1, E = SectionVal.find(',', B); SMLoc BLoc = SMLoc::getFromPointer(SectionVal.data() + B); diff --git a/llvm/lib/MC/MCSymbolXCOFF.cpp b/llvm/lib/MC/MCSymbolXCOFF.cpp index b4c96a1ffa233..599a3946a1ed7 100644 --- a/llvm/lib/MC/MCSymbolXCOFF.cpp +++ b/llvm/lib/MC/MCSymbolXCOFF.cpp @@ -13,7 +13,7 @@ using namespace llvm; MCSectionXCOFF *MCSymbolXCOFF::getRepresentedCsect() const { assert(RepresentedCsect && "Trying to get csect representation of this symbol but none was set."); - assert(getSymbolTableName().equals(RepresentedCsect->getSymbolTableName()) && + assert(getSymbolTableName() == RepresentedCsect->getSymbolTableName() && "SymbolTableNames need to be the same for this symbol and its csect " "representation."); return RepresentedCsect; @@ -24,7 +24,7 @@ void MCSymbolXCOFF::setRepresentedCsect(MCSectionXCOFF *C) { assert((!RepresentedCsect || RepresentedCsect == C) && "Trying to set a csect that doesn't match the one that this symbol is " "already mapped to."); - assert(getSymbolTableName().equals(C->getSymbolTableName()) && + assert(getSymbolTableName() == C->getSymbolTableName() && "SymbolTableNames need to be the same for this symbol and its csect " "representation."); RepresentedCsect = C; diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp index 6139d9996bdad..e798bbdd16f14 100644 --- a/llvm/lib/Object/Archive.cpp +++ b/llvm/lib/Object/Archive.cpp @@ -269,11 +269,11 @@ Expected ArchiveMemberHeader::getName(uint64_t Size) const { return Name; // System libraries from the Windows SDK for Windows 11 contain this symbol. // It looks like a CFG guard: we just skip it for now. - if (Name.equals("//")) + if (Name == "//") return Name; // Some libraries (e.g., arm64rt.lib) from the Windows WDK // (version 10.0.22000.0) contain this undocumented special member. - if (Name.equals("//")) + if (Name == "//") return Name; // It's a long name. // Get the string table offset. diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 1cfd0a069463e..06186ad362aad 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -399,7 +399,7 @@ static Error parseSegmentLoadCommand( return malformedError("load command " + Twine(LoadCommandIndex) + " filesize field in " + CmdName + " greater than vmsize field"); - IsPageZeroSegment |= StringRef("__PAGEZERO").equals(S.segname); + IsPageZeroSegment |= StringRef("__PAGEZERO") == S.segname; } else return SegOrErr.takeError(); @@ -4364,7 +4364,7 @@ BindRebaseSegInfo::BindRebaseSegInfo(const object::MachOObjectFile *Obj) { Info.Size = Section.getSize(); Info.SegmentName = Obj->getSectionFinalSegmentName(Section.getRawDataRefImpl()); - if (!Info.SegmentName.equals(CurSegName)) { + if (Info.SegmentName != CurSegName) { ++CurSegIndex; CurSegName = Info.SegmentName; CurSegAddress = Info.Address; diff --git a/llvm/lib/Object/OffloadBinary.cpp b/llvm/lib/Object/OffloadBinary.cpp index 6e9f8bed513c1..89dc12551494f 100644 --- a/llvm/lib/Object/OffloadBinary.cpp +++ b/llvm/lib/Object/OffloadBinary.cpp @@ -359,7 +359,7 @@ bool object::areTargetsCompatible(const OffloadFile::TargetID &LHS, return false; // If the architecture is "all" we assume it is always compatible. - if (LHS.second.equals("generic") || RHS.second.equals("generic")) + if (LHS.second == "generic" || RHS.second == "generic") return true; // Only The AMDGPU target requires additional checks. diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp index 7088223b9b672..bb46de4c6f57f 100644 --- a/llvm/lib/ObjectYAML/COFFEmitter.cpp +++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp @@ -359,9 +359,9 @@ static uint32_t initializeOptionalHeader(COFFParser &CP, uint16_t Magic, SizeOfInitializedData += S.Header.SizeOfRawData; if (S.Header.Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) SizeOfUninitializedData += S.Header.SizeOfRawData; - if (S.Name.equals(".text")) + if (S.Name == ".text") Header->BaseOfCode = S.Header.VirtualAddress; // RVA - else if (S.Name.equals(".data")) + else if (S.Name == ".data") BaseOfData = S.Header.VirtualAddress; // RVA if (S.Header.VirtualAddress) SizeOfImage += alignTo(S.Header.VirtualSize, Header->SectionAlignment); diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp index 79aff096fb085..c7adc7668b9a1 100644 --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -822,8 +822,7 @@ PrintIRInstrumentation::PassRunDescriptor PrintIRInstrumentation::popPassRunDescriptor(StringRef PassID) { assert(!PassRunDescriptorStack.empty() && "empty PassRunDescriptorStack"); PassRunDescriptor Descriptor = PassRunDescriptorStack.pop_back_val(); - assert(Descriptor.PassID.equals(PassID) && - "malformed PassRunDescriptorStack"); + assert(Descriptor.PassID == PassID && "malformed PassRunDescriptorStack"); return Descriptor; } diff --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp index ee61784abade5..ecb12c045b5b1 100644 --- a/llvm/lib/ProfileData/GCOV.cpp +++ b/llvm/lib/ProfileData/GCOV.cpp @@ -678,7 +678,7 @@ std::string Context::getCoveragePath(StringRef filename, return std::string(filename); std::string CoveragePath; - if (options.LongFileNames && !filename.equals(mainFilename)) + if (options.LongFileNames && filename != mainFilename) CoveragePath = mangleCoveragePath(mainFilename, options.PreservePaths) + "##"; CoveragePath += mangleCoveragePath(filename, options.PreservePaths); diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index f9ba80bd99c85..1e3ca47b3d5aa 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -1283,7 +1283,7 @@ MDNode *mayHaveValueProfileOfKind(const Instruction &Inst, return nullptr; MDString *Tag = cast(MD->getOperand(0)); - if (!Tag || !Tag->getString().equals("VP")) + if (!Tag || Tag->getString() != "VP") return nullptr; // Now check kind: diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp index b4d2c6f043f6d..c25babac844ac 100644 --- a/llvm/lib/ProfileData/MemProfReader.cpp +++ b/llvm/lib/ProfileData/MemProfReader.cpp @@ -164,9 +164,9 @@ bool isRuntimePath(const StringRef Path) { const StringRef Filename = llvm::sys::path::filename(Path); // This list should be updated in case new files with additional interceptors // are added to the memprof runtime. - return Filename.equals("memprof_malloc_linux.cpp") || - Filename.equals("memprof_interceptors.cpp") || - Filename.equals("memprof_new_delete.cpp"); + return Filename == "memprof_malloc_linux.cpp" || + Filename == "memprof_interceptors.cpp" || + Filename == "memprof_new_delete.cpp"; } std::string getBuildIdString(const SegmentEntry &Entry) { diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 54b9c38f76095..fcefdef992be5 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1725,7 +1725,7 @@ class llvm::vfs::RedirectingFileSystemParser { RedirectingFileSystem::Entry *ParentEntry = nullptr) { if (!ParentEntry) { // Look for a existent root for (const auto &Root : FS->Roots) { - if (Name.equals(Root->getName())) { + if (Name == Root->getName()) { ParentEntry = Root.get(); return ParentEntry; } @@ -1736,7 +1736,7 @@ class llvm::vfs::RedirectingFileSystemParser { llvm::make_range(DE->contents_begin(), DE->contents_end())) { auto *DirContent = dyn_cast(Content.get()); - if (DirContent && Name.equals(Content->getName())) + if (DirContent && Name == Content->getName()) return DirContent; } } diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp b/llvm/lib/TargetParser/ARMTargetParser.cpp index 67f937ebc33f9..9d9917d86a368 100644 --- a/llvm/lib/TargetParser/ARMTargetParser.cpp +++ b/llvm/lib/TargetParser/ARMTargetParser.cpp @@ -610,7 +610,7 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) { return StringRef(); StringRef CPU = llvm::ARM::getDefaultCPU(MArch); - if (!CPU.empty() && !CPU.equals("invalid")) + if (!CPU.empty() && CPU != "invalid") return CPU; // If no specific architecture version is requested, return the minimum CPU diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index f3f244c814e7e..b4b2fa3b0b85e 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -348,14 +348,14 @@ StringRef Triple::getObjectFormatTypeName(ObjectFormatType Kind) { } static Triple::ArchType parseBPFArch(StringRef ArchName) { - if (ArchName.equals("bpf")) { + if (ArchName == "bpf") { if (sys::IsLittleEndianHost) return Triple::bpfel; else return Triple::bpfeb; - } else if (ArchName.equals("bpf_be") || ArchName.equals("bpfeb")) { + } else if (ArchName == "bpf_be" || ArchName == "bpfeb") { return Triple::bpfeb; - } else if (ArchName.equals("bpf_le") || ArchName.equals("bpfel")) { + } else if (ArchName == "bpf_le" || ArchName == "bpfel") { return Triple::bpfel; } else { return Triple::UnknownArch; diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp index 7246ba45d5afc..83473704398df 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -705,7 +705,7 @@ bool DwarfLinkerForBinary::linkImpl( } else { // Try and emit more helpful warnings by applying some heuristics. StringRef ObjFile = ContainerName; - bool IsClangModule = sys::path::extension(Path).equals(".pcm"); + bool IsClangModule = sys::path::extension(Path) == ".pcm"; bool IsArchive = ObjFile.ends_with(")"); if (IsClangModule) { diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp index 96841c3c387bd..1846f9265c755 100644 --- a/llvm/tools/llvm-dwarfdump/Statistics.cpp +++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp @@ -229,7 +229,7 @@ static std::string constructDieID(DWARFDie Die, << Die.getName(DINameKind::LinkageName); // Prefix + Name is enough for local variables and parameters. - if (!Prefix.empty() && !Prefix.equals("g")) + if (!Prefix.empty() && Prefix != "g") return ID.str(); auto DeclFile = Die.findRecursively(dwarf::DW_AT_decl_file); diff --git a/llvm/tools/llvm-extract/llvm-extract.cpp b/llvm/tools/llvm-extract/llvm-extract.cpp index a879c203fc374..5915f92ea05c3 100644 --- a/llvm/tools/llvm-extract/llvm-extract.cpp +++ b/llvm/tools/llvm-extract/llvm-extract.cpp @@ -357,7 +357,7 @@ int main(int argc, char **argv) { // The function has been materialized, so add its matching basic blocks // to the block extractor list, or fail if a name is not found. auto Res = llvm::find_if(*P.first, [&](const BasicBlock &BB) { - return BB.getName().equals(BBName); + return BB.getName() == BBName; }); if (Res == P.first->end()) { errs() << argv[0] << ": function " << P.first->getName() diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 5e0d69a68d69b..749f988201757 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -2148,7 +2148,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF, else consumeError(NameOrErr.takeError()); - if (SectName.equals("__text")) { + if (SectName == "__text") { DataRefImpl Ref = Section.getRawDataRefImpl(); StringRef SegName = MachOOF->getSectionFinalSegmentName(Ref); DisassembleMachO(FileName, MachOOF, SegName, SectName); diff --git a/llvm/tools/llvm-xray/xray-graph-diff.cpp b/llvm/tools/llvm-xray/xray-graph-diff.cpp index 899a6725a5d3e..b5c63ab0a9183 100644 --- a/llvm/tools/llvm-xray/xray-graph-diff.cpp +++ b/llvm/tools/llvm-xray/xray-graph-diff.cpp @@ -381,14 +381,14 @@ void GraphDiffRenderer::exportGraphAsDOT(raw_ostream &OS, StatType EdgeLabel, R"(color="{5}" labelfontcolor="{5}" penwidth={6}])" "\n", VertexNo[HeadId], VertexNo[TailId], - (HeadId.equals("")) ? static_cast("F0") : HeadId, + HeadId.empty() ? static_cast("F0") : HeadId, TailId, getLabel(E, EdgeLabel), getColor(E, G, H, EdgeColor), getLineWidth(E, EdgeColor)); } for (const auto &V : G.vertices()) { const auto &VertexId = V.first; - if (VertexId.equals("")) { + if (VertexId.empty()) { OS << formatv(R"(F{0} [label="F0"])" "\n", VertexNo[VertexId]); diff --git a/llvm/tools/llvm-yaml-numeric-parser-fuzzer/yaml-numeric-parser-fuzzer.cpp b/llvm/tools/llvm-yaml-numeric-parser-fuzzer/yaml-numeric-parser-fuzzer.cpp index c8370289963db..9a572c1e06005 100644 --- a/llvm/tools/llvm-yaml-numeric-parser-fuzzer/yaml-numeric-parser-fuzzer.cpp +++ b/llvm/tools/llvm-yaml-numeric-parser-fuzzer/yaml-numeric-parser-fuzzer.cpp @@ -18,7 +18,7 @@ inline bool isNumericRegex(llvm::StringRef S) { static llvm::Regex Float( "^[-+]?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$"); - if (S.equals(".nan") || S.equals(".NaN") || S.equals(".NAN")) + if (S == ".nan" || S == ".NaN" || S == ".NAN") return true; if (Infinity.match(S)) diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp index fa537e816fc8e..b3c206a336962 100644 --- a/llvm/unittests/ADT/StringRefTest.cpp +++ b/llvm/unittests/ADT/StringRefTest.cpp @@ -998,7 +998,7 @@ TEST(StringRefTest, AllocatorCopy) { // allocator. StringRef StrEmpty = ""; StringRef StrEmptyc = StrEmpty.copy(Alloc); - EXPECT_TRUE(StrEmpty.equals(StrEmptyc)); + EXPECT_TRUE(StrEmpty == StrEmptyc); EXPECT_EQ(StrEmptyc.data(), nullptr); EXPECT_EQ(StrEmptyc.size(), 0u); EXPECT_EQ(Alloc.getTotalMemory(), 0u); @@ -1007,9 +1007,9 @@ TEST(StringRefTest, AllocatorCopy) { StringRef Str2 = "bye"; StringRef Str1c = Str1.copy(Alloc); StringRef Str2c = Str2.copy(Alloc); - EXPECT_TRUE(Str1.equals(Str1c)); + EXPECT_TRUE(Str1 == Str1c); EXPECT_NE(Str1.data(), Str1c.data()); - EXPECT_TRUE(Str2.equals(Str2c)); + EXPECT_TRUE(Str2 == Str2c); EXPECT_NE(Str2.data(), Str2c.data()); } diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index c8db7fb7ab843..d79b4f3d8a444 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -173,27 +173,27 @@ TEST(VerifierTest, CrossModuleRef) { std::string Error; raw_string_ostream ErrorOS(Error); EXPECT_TRUE(verifyModule(M2, &ErrorOS)); - EXPECT_TRUE(StringRef(ErrorOS.str()) - .equals("Global is referenced in a different module!\n" - "ptr @foo2\n" - "; ModuleID = 'M2'\n" - " %call = call i32 @foo2()\n" - "ptr @foo1\n" - "; ModuleID = 'M1'\n" - "Global is used by function in a different module\n" - "ptr @foo2\n" - "; ModuleID = 'M2'\n" - "ptr @foo3\n" - "; ModuleID = 'M3'\n")); + EXPECT_TRUE(StringRef(ErrorOS.str()) == + "Global is referenced in a different module!\n" + "ptr @foo2\n" + "; ModuleID = 'M2'\n" + " %call = call i32 @foo2()\n" + "ptr @foo1\n" + "; ModuleID = 'M1'\n" + "Global is used by function in a different module\n" + "ptr @foo2\n" + "; ModuleID = 'M2'\n" + "ptr @foo3\n" + "; ModuleID = 'M3'\n"); Error.clear(); EXPECT_TRUE(verifyModule(M1, &ErrorOS)); - EXPECT_TRUE(StringRef(ErrorOS.str()).equals( - "Referencing function in another module!\n" - " %call = call i32 @foo2()\n" - "; ModuleID = 'M1'\n" - "ptr @foo2\n" - "; ModuleID = 'M2'\n")); + EXPECT_TRUE(StringRef(ErrorOS.str()) == + "Referencing function in another module!\n" + " %call = call i32 @foo2()\n" + "; ModuleID = 'M1'\n" + "ptr @foo2\n" + "; ModuleID = 'M2'\n"); Error.clear(); EXPECT_TRUE(verifyModule(M3, &ErrorOS)); diff --git a/llvm/unittests/Support/MemoryBufferTest.cpp b/llvm/unittests/Support/MemoryBufferTest.cpp index cfee3e477d2ed..4815e65c968d0 100644 --- a/llvm/unittests/Support/MemoryBufferTest.cpp +++ b/llvm/unittests/Support/MemoryBufferTest.cpp @@ -317,13 +317,13 @@ TEST_F(MemoryBufferTest, slice) { EXPECT_EQ(0x4000UL, MB.get()->getBufferSize()); StringRef BufData = MB.get()->getBuffer(); - EXPECT_TRUE(BufData.substr(0x0000,8).equals("12345678")); - EXPECT_TRUE(BufData.substr(0x0FF8,8).equals("12345678")); - EXPECT_TRUE(BufData.substr(0x1000,8).equals("abcdefgh")); - EXPECT_TRUE(BufData.substr(0x2FF8,8).equals("abcdefgh")); - EXPECT_TRUE(BufData.substr(0x3000,8).equals("ABCDEFGH")); - EXPECT_TRUE(BufData.substr(0x3FF8,8).equals("ABCDEFGH")); - + EXPECT_TRUE(BufData.substr(0x0000, 8) == "12345678"); + EXPECT_TRUE(BufData.substr(0x0FF8, 8) == "12345678"); + EXPECT_TRUE(BufData.substr(0x1000, 8) == "abcdefgh"); + EXPECT_TRUE(BufData.substr(0x2FF8, 8) == "abcdefgh"); + EXPECT_TRUE(BufData.substr(0x3000, 8) == "ABCDEFGH"); + EXPECT_TRUE(BufData.substr(0x3FF8, 8) == "ABCDEFGH"); + // Try non-page aligned. ErrorOr MB2 = MemoryBuffer::getFileSlice(TestPath.str(), 0x3000, 0x0800); @@ -332,10 +332,10 @@ TEST_F(MemoryBufferTest, slice) { EXPECT_EQ(0x3000UL, MB2.get()->getBufferSize()); StringRef BufData2 = MB2.get()->getBuffer(); - EXPECT_TRUE(BufData2.substr(0x0000,8).equals("12345678")); - EXPECT_TRUE(BufData2.substr(0x17F8,8).equals("12345678")); - EXPECT_TRUE(BufData2.substr(0x1800,8).equals("abcdefgh")); - EXPECT_TRUE(BufData2.substr(0x2FF8,8).equals("abcdefgh")); + EXPECT_TRUE(BufData2.substr(0x0000, 8) == "12345678"); + EXPECT_TRUE(BufData2.substr(0x17F8, 8) == "12345678"); + EXPECT_TRUE(BufData2.substr(0x1800, 8) == "abcdefgh"); + EXPECT_TRUE(BufData2.substr(0x2FF8, 8) == "abcdefgh"); } TEST_F(MemoryBufferTest, writableSlice) { diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp index 6ac0d1b412f0a..9d40b62115a67 100644 --- a/llvm/unittests/Support/YAMLIOTest.cpp +++ b/llvm/unittests/Support/YAMLIOTest.cpp @@ -1389,10 +1389,10 @@ TEST(YAMLIO, TestReadWriteMyFlowSequence) { yin >> map2; EXPECT_FALSE(yin.error()); - EXPECT_TRUE(map2.name.equals("hello")); + EXPECT_TRUE(map2.name == "hello"); EXPECT_EQ(map2.strings.size(), 2UL); - EXPECT_TRUE(map2.strings[0].value.equals("one")); - EXPECT_TRUE(map2.strings[1].value.equals("two")); + EXPECT_TRUE(map2.strings[0].value == "one"); + EXPECT_TRUE(map2.strings[1].value == "two"); EXPECT_EQ(map2.single.size(), 1UL); EXPECT_EQ(1, map2.single[0]); EXPECT_EQ(map2.numbers.size(), 3UL); @@ -1436,7 +1436,7 @@ TEST(YAMLIO, TestReadWriteSequenceOfMyFlowSequence) { yin >> map2; EXPECT_FALSE(yin.error()); - EXPECT_TRUE(map2.name.equals("hello")); + EXPECT_TRUE(map2.name == "hello"); EXPECT_EQ(map2.sequenceOfNumbers.size(), 3UL); EXPECT_EQ(map2.sequenceOfNumbers[0].size(), 1UL); EXPECT_EQ(0, map2.sequenceOfNumbers[0][0]); diff --git a/llvm/unittests/TargetParser/CSKYTargetParserTest.cpp b/llvm/unittests/TargetParser/CSKYTargetParserTest.cpp index f28a2a33eb90c..50e825c5f99fe 100644 --- a/llvm/unittests/TargetParser/CSKYTargetParserTest.cpp +++ b/llvm/unittests/TargetParser/CSKYTargetParserTest.cpp @@ -1020,7 +1020,7 @@ TEST(TargetParserTest, testInvalidCSKYArch) { bool testCSKYArch(StringRef Arch, StringRef DefaultCPU) { CSKY::ArchKind AK = CSKY::parseArch(Arch); bool Result = (AK != CSKY::ArchKind::INVALID); - Result &= CSKY::getDefaultCPU(Arch).equals(DefaultCPU); + Result &= CSKY::getDefaultCPU(Arch) == DefaultCPU; return Result; } diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp index cc098c264065f..b61928bd8f986 100644 --- a/llvm/unittests/TargetParser/TargetParserTest.cpp +++ b/llvm/unittests/TargetParser/TargetParserTest.cpp @@ -572,8 +572,8 @@ bool testARMArch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch, unsigned ArchAttr) { ARM::ArchKind AK = ARM::parseArch(Arch); bool Result = (AK != ARM::ArchKind::INVALID); - Result &= ARM::getDefaultCPU(Arch).equals(DefaultCPU); - Result &= ARM::getSubArch(AK).equals(SubArch); + Result &= ARM::getDefaultCPU(Arch) == DefaultCPU; + Result &= ARM::getSubArch(AK) == SubArch; Result &= (ARM::getArchAttr(AK) == ArchAttr); return Result; } diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 53d49a2900a15..8e475f9153b0d 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -3121,7 +3121,7 @@ static void emitMnemonicSpellChecker(raw_ostream &OS, CodeGenTarget &Target, OS << "\n"; OS << " StringRef T = I->getMnemonic();\n"; OS << " // Avoid recomputing the edit distance for the same string.\n"; - OS << " if (T.equals(Prev))\n"; + OS << " if (T == Prev)\n"; OS << " continue;\n"; OS << "\n"; OS << " Prev = T;\n";