diff options
author | Kazu Hirata <kazu@google.com> | 2023-12-11 21:01:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 21:01:36 -0800 |
commit | 586ecdf205aa8b3d162da6f955170a6736656615 (patch) | |
tree | 75cbe2050cd2f1a06a656be8b845f82433970ff3 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | d5fb4c0f118b47db74233af2d99ae075e1dbe148 (diff) | |
download | llvm-586ecdf205aa8b3d162da6f955170a6736656615.zip llvm-586ecdf205aa8b3d162da6f955170a6736656615.tar.gz llvm-586ecdf205aa8b3d162da6f955170a6736656615.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 9827bd3..27d47aa 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) { |