From 586ecdf205aa8b3d162da6f955170a6736656615 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 11 Dec 2023 21:01:36 -0800 Subject: [llvm] Use StringRef::{starts,ends}_with (NFC) (#74956) This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with. --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 33 ++++++++++------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 9827bd3ff4f1..27d47aab4b68 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -478,26 +478,21 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) { if (Name.empty() || Name[0] != '.') return K; // Default implementation based on some magic section names. - if (Name == ".bss" || - Name.startswith(".bss.") || - Name.startswith(".gnu.linkonce.b.") || - Name.startswith(".llvm.linkonce.b.") || - Name == ".sbss" || - Name.startswith(".sbss.") || - Name.startswith(".gnu.linkonce.sb.") || - Name.startswith(".llvm.linkonce.sb.")) + if (Name == ".bss" || Name.starts_with(".bss.") || + Name.starts_with(".gnu.linkonce.b.") || + Name.starts_with(".llvm.linkonce.b.") || Name == ".sbss" || + Name.starts_with(".sbss.") || Name.starts_with(".gnu.linkonce.sb.") || + Name.starts_with(".llvm.linkonce.sb.")) return SectionKind::getBSS(); - if (Name == ".tdata" || - Name.startswith(".tdata.") || - Name.startswith(".gnu.linkonce.td.") || - Name.startswith(".llvm.linkonce.td.")) + if (Name == ".tdata" || Name.starts_with(".tdata.") || + Name.starts_with(".gnu.linkonce.td.") || + Name.starts_with(".llvm.linkonce.td.")) return SectionKind::getThreadData(); - if (Name == ".tbss" || - Name.startswith(".tbss.") || - Name.startswith(".gnu.linkonce.tb.") || - Name.startswith(".llvm.linkonce.tb.")) + if (Name == ".tbss" || Name.starts_with(".tbss.") || + Name.starts_with(".gnu.linkonce.tb.") || + Name.starts_with(".llvm.linkonce.tb.")) return SectionKind::getThreadBSS(); return K; @@ -512,7 +507,7 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) { // Use SHT_NOTE for section whose name starts with ".note" to allow // emitting ELF notes from C variable declaration. // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77609 - if (Name.startswith(".note")) + if (Name.starts_with(".note")) return ELF::SHT_NOTE; if (hasPrefix(Name, ".init_array")) @@ -752,7 +747,7 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, getELFSectionNameForGlobal(GO, Kind, Mang, TM, EntrySize, false); if (SymbolMergeable && Ctx.isELFImplicitMergeableSectionNamePrefix(SectionName) && - SectionName.startswith(ImplicitSectionNameStem)) + SectionName.starts_with(ImplicitSectionNameStem)) return MCContext::GenericSectionID; // We have seen this section name before, but with different flags or entity @@ -1036,7 +1031,7 @@ MCSection *TargetLoweringObjectFileELF::getSectionForMachineBasicBlock( SmallString<128> Name; StringRef FunctionSectionName = MBB.getParent()->getSection()->getName(); if (FunctionSectionName.equals(".text") || - FunctionSectionName.startswith(".text.")) { + FunctionSectionName.starts_with(".text.")) { // Function is in a regular .text section. StringRef FunctionName = MBB.getParent()->getName(); if (MBB.getSectionID() == MBBSectionID::ColdSectionID) { -- cgit v1.2.3