[llvm] [llvm] Use StringRef::{starts,ends}_with (NFC) (PR #74956)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 08:57:12 PST 2023
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/74956
>From 63fc6677f49eebea178ff4bcd20b2fc68db39cc0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 9 Dec 2023 15:37:55 -0800
Subject: [PATCH 1/2] [llvm] Use StringRef::{starts,ends}_with (NFC)
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/Analysis/ObjCARCAnalysisUtils.h | 2 +-
llvm/include/llvm/CodeGen/IndirectThunks.h | 4 +-
llvm/include/llvm/CodeGen/MIRYamlMapping.h | 4 +-
llvm/include/llvm/MC/MCSectionCOFF.h | 2 +-
llvm/include/llvm/Object/ELFObjectFile.h | 14 +--
llvm/include/llvm/Passes/PassBuilder.h | 6 +-
llvm/include/llvm/ProfileData/SampleProf.h | 2 +-
llvm/include/llvm/Transforms/IPO/Attributor.h | 4 +-
llvm/lib/Analysis/LoopInfo.cpp | 2 +-
llvm/lib/Analysis/VFABIDemangling.cpp | 2 +-
llvm/lib/AsmParser/LLLexer.cpp | 6 +-
llvm/lib/BinaryFormat/Magic.cpp | 6 +-
llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 2 +-
.../BasicBlockSectionsProfileReader.cpp | 2 +-
llvm/lib/CodeGen/GlobalMerge.cpp | 4 +-
llvm/lib/CodeGen/MIRParser/MILexer.cpp | 16 +--
llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp | 2 +-
.../CodeGen/TargetLoweringObjectFileImpl.cpp | 30 +++---
llvm/lib/CodeGen/WinEHPrepare.cpp | 2 +-
llvm/lib/DWARFLinker/DWARFLinker.cpp | 6 +-
.../DWARFLinkerCompileUnit.cpp | 6 +-
.../SyntheticTypeNameBuilder.cpp | 2 +-
.../ExecutionEngine/JITLink/ELF_x86_64.cpp | 4 +-
.../JITLink/MachOLinkGraphBuilder.cpp | 2 +-
.../Orc/Debugging/DebugInfoSupport.cpp | 2 +-
.../Orc/Debugging/DebuggerSupportPlugin.cpp | 2 +-
.../ExecutionEngine/Orc/ExecutionUtils.cpp | 6 +-
.../ExecutionEngine/Orc/IndirectionUtils.cpp | 2 +-
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 4 +-
.../Orc/ObjectFileInterface.cpp | 2 +-
.../Orc/Shared/ObjectFormats.cpp | 2 +-
.../ExecutionEngine/RuntimeDyld/JITSymbol.cpp | 2 +-
.../RuntimeDyld/RuntimeDyldCOFF.cpp | 3 +-
.../RuntimeDyld/RuntimeDyldChecker.cpp | 52 +++++-----
.../Targets/RuntimeDyldCOFFAArch64.h | 2 +-
.../RuntimeDyld/Targets/RuntimeDyldCOFFI386.h | 2 +-
.../Targets/RuntimeDyldCOFFThumb.h | 2 +-
.../Targets/RuntimeDyldCOFFX86_64.h | 2 +-
llvm/lib/FileCheck/FileCheck.cpp | 32 +++---
llvm/lib/FuzzMutate/FuzzerCLI.cpp | 4 +-
llvm/lib/IR/AutoUpgrade.cpp | 2 +-
llvm/lib/IR/DebugInfo.cpp | 2 +-
llvm/lib/IR/Function.cpp | 6 +-
llvm/lib/IR/Mangler.cpp | 4 +-
llvm/lib/IR/PassInstrumentation.cpp | 3 +-
llvm/lib/IR/Type.cpp | 2 +-
llvm/lib/IR/Verifier.cpp | 2 +-
llvm/lib/InterfaceStub/IFSHandler.cpp | 2 +-
llvm/lib/LTO/LTOModule.cpp | 8 +-
llvm/lib/Linker/IRMover.cpp | 2 +-
llvm/lib/MC/ELFObjectWriter.cpp | 12 +--
llvm/lib/MC/MCAsmStreamer.cpp | 6 +-
llvm/lib/MC/MCContext.cpp | 10 +-
llvm/lib/MC/MCDwarf.cpp | 2 +-
llvm/lib/MC/MCParser/AsmLexer.cpp | 4 +-
llvm/lib/MC/MCParser/AsmParser.cpp | 2 +-
llvm/lib/MC/MCParser/COFFMasmParser.cpp | 2 +-
llvm/lib/MC/MCParser/ELFAsmParser.cpp | 4 +-
llvm/lib/MC/MCParser/MasmParser.cpp | 4 +-
llvm/lib/MC/StringTableBuilder.cpp | 2 +-
llvm/lib/MC/WasmObjectWriter.cpp | 12 +--
llvm/lib/MC/WinCOFFObjectWriter.cpp | 2 +-
llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp | 2 +-
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp | 16 +--
llvm/lib/ObjCopy/MachO/MachOObject.h | 4 +-
llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp | 4 +-
llvm/lib/Object/Archive.cpp | 16 +--
llvm/lib/Object/COFFImportFile.cpp | 6 +-
llvm/lib/Object/COFFModuleDefinition.cpp | 4 +-
llvm/lib/Object/COFFObjectFile.cpp | 6 +-
llvm/lib/Object/MachOObjectFile.cpp | 10 +-
llvm/lib/Object/ModuleSymbolTable.cpp | 2 +-
llvm/lib/Object/RecordStreamer.cpp | 2 +-
llvm/lib/Object/WasmObjectFile.cpp | 2 +-
llvm/lib/ObjectYAML/ELFEmitter.cpp | 2 +-
llvm/lib/ObjectYAML/ELFYAML.cpp | 6 +-
llvm/lib/Option/ArgList.cpp | 2 +-
llvm/lib/Option/OptTable.cpp | 12 +--
llvm/lib/Passes/PassBuilder.cpp | 6 +-
llvm/lib/ProfileData/GCOV.cpp | 2 +-
llvm/lib/ProfileData/InstrProf.cpp | 2 +-
llvm/lib/ProfileData/InstrProfCorrelator.cpp | 2 +-
llvm/lib/ProfileData/InstrProfReader.cpp | 8 +-
.../ItaniumManglingCanonicalizer.cpp | 6 +-
llvm/lib/ProfileData/SampleProfReader.cpp | 4 +-
.../lib/ProfileData/SymbolRemappingReader.cpp | 2 +-
llvm/lib/Remarks/YAMLRemarkParser.cpp | 2 +-
llvm/lib/Support/Unix/Path.inc | 2 +-
.../Target/AArch64/AArch64GlobalsTagging.cpp | 2 +-
.../Target/AArch64/AArch64SLSHardening.cpp | 2 +-
.../AArch64/AsmParser/AArch64AsmParser.cpp | 4 +-
llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp | 2 +-
.../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 4 +-
.../Target/AMDGPU/AMDGPUTargetObjectFile.cpp | 2 +-
.../AMDGPU/AMDGPUTargetTransformInfo.cpp | 2 +-
.../AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 32 +++---
.../Disassembler/AMDGPUDisassembler.cpp | 2 +-
.../R600OpenCLImageTypeLoweringPass.cpp | 6 +-
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 2 +-
.../Target/AMDGPU/SIMachineFunctionInfo.cpp | 2 +-
.../Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp | 10 +-
llvm/lib/Target/ARM/ARMSLSHardening.cpp | 2 +-
llvm/lib/Target/ARM/ARMTargetMachine.cpp | 4 +-
.../lib/Target/ARM/ARMTargetTransformInfo.cpp | 2 +-
.../lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 98 +++++++++----------
.../ARM/MCTargetDesc/ARMTargetStreamer.cpp | 2 +-
llvm/lib/Target/AVR/AVRAsmPrinter.cpp | 6 +-
.../Target/BPF/BPFAbstractMemberAccess.cpp | 12 +--
llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp | 4 +-
llvm/lib/Target/BPF/BPFPreserveDIType.cpp | 2 +-
llvm/lib/Target/BPF/BTFDebug.cpp | 6 +-
llvm/lib/Target/Hexagon/HexagonSubtarget.cpp | 6 +-
.../Hexagon/HexagonTargetObjectFile.cpp | 2 +-
.../MCTargetDesc/HexagonMCTargetDesc.cpp | 2 +-
.../Target/Lanai/AsmParser/LanaiAsmParser.cpp | 14 +--
.../Target/Lanai/LanaiTargetObjectFile.cpp | 2 +-
.../LoongArch/LoongArchISelLowering.cpp | 4 +-
.../Target/Mips/AsmParser/MipsAsmParser.cpp | 6 +-
.../Target/Mips/MCTargetDesc/MipsABIInfo.cpp | 6 +-
llvm/lib/Target/Mips/MipsISelLowering.cpp | 2 +-
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 4 +-
llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp | 2 +-
.../Target/NVPTX/NVPTXReplaceImageHandles.cpp | 2 +-
.../Target/PowerPC/AsmParser/PPCAsmParser.cpp | 2 +-
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +-
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 4 +-
.../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 4 +-
.../RISCV/MCTargetDesc/RISCVBaseInfo.cpp | 4 +-
.../SystemZ/AsmParser/SystemZAsmParser.cpp | 2 +-
llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp | 30 +++---
.../AsmParser/WebAssemblyAsmParser.cpp | 2 +-
.../WebAssembly/WebAssemblyAsmPrinter.cpp | 4 +-
.../WebAssemblyLowerEmscriptenEHSjLj.cpp | 4 +-
.../lib/Target/X86/AsmParser/X86AsmParser.cpp | 70 ++++++-------
.../X86/MCTargetDesc/X86MCTargetDesc.cpp | 4 +-
llvm/lib/Target/X86/X86InsertPrefetch.cpp | 2 +-
llvm/lib/Target/X86/X86Subtarget.cpp | 4 +-
llvm/lib/Target/XCore/XCoreISelLowering.cpp | 2 +-
.../Target/XCore/XCoreTargetObjectFile.cpp | 2 +-
llvm/lib/TargetParser/AArch64TargetParser.cpp | 4 +-
llvm/lib/TargetParser/ARMTargetParser.cpp | 4 +-
.../TargetParser/ARMTargetParserCommon.cpp | 26 ++---
llvm/lib/TargetParser/CSKYTargetParser.cpp | 2 +-
llvm/lib/TargetParser/Host.cpp | 14 +--
llvm/lib/TargetParser/Triple.cpp | 29 +++---
llvm/lib/TextAPI/Symbol.cpp | 10 +-
llvm/lib/TextAPI/Target.cpp | 2 +-
llvm/lib/TextAPI/TextStub.cpp | 18 ++--
llvm/tools/dsymutil/BinaryHolder.cpp | 2 +-
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp | 4 +-
llvm/tools/dsymutil/MachODebugMapParser.cpp | 4 +-
llvm/tools/dsymutil/MachOUtils.cpp | 2 +-
llvm/tools/dsymutil/SymbolMap.cpp | 4 +-
llvm/tools/llc/llc.cpp | 6 +-
llvm/tools/lli/lli.cpp | 2 +-
llvm/tools/llvm-ar/llvm-ar.cpp | 4 +-
llvm/tools/llvm-as/llvm-as.cpp | 2 +-
llvm/tools/llvm-config/llvm-config.cpp | 10 +-
llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp | 28 +++---
llvm/tools/llvm-diff/llvm-diff.cpp | 3 +-
llvm/tools/llvm-dis/llvm-dis.cpp | 2 +-
llvm/tools/llvm-dwarfutil/DebugInfoLinker.h | 2 +-
llvm/tools/llvm-exegesis/lib/X86/Target.cpp | 6 +-
llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 6 +-
.../llvm-libtool-darwin.cpp | 2 +-
llvm/tools/llvm-nm/llvm-nm.cpp | 14 +--
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | 2 +-
llvm/tools/llvm-objdump/COFFDump.cpp | 2 +-
llvm/tools/llvm-objdump/MachODump.cpp | 4 +-
llvm/tools/llvm-objdump/SourcePrinter.cpp | 2 +-
llvm/tools/llvm-objdump/llvm-objdump.cpp | 2 +-
llvm/tools/llvm-profdata/llvm-profdata.cpp | 2 +-
llvm/tools/llvm-profgen/PerfReader.cpp | 12 +--
.../tools/llvm-rc/ResourceScriptCppFilter.cpp | 2 +-
llvm/tools/llvm-rc/ResourceScriptToken.cpp | 6 +-
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp | 2 +-
llvm/tools/llvm-readobj/COFFDumper.cpp | 2 +-
llvm/tools/llvm-readobj/ELFDumper.cpp | 6 +-
llvm/tools/llvm-readobj/Win64EHDumper.cpp | 2 +-
.../llvm-reduce/deltas/StripDebugInfo.cpp | 2 +-
llvm/tools/llvm-reduce/llvm-reduce.cpp | 2 +-
llvm/tools/llvm-stress/llvm-stress.cpp | 2 +-
llvm/tools/llvm-undname/llvm-undname.cpp | 2 +-
llvm/tools/obj2yaml/archive2yaml.cpp | 2 +-
llvm/tools/obj2yaml/elf2yaml.cpp | 2 +-
llvm/tools/obj2yaml/macho2yaml.cpp | 6 +-
llvm/tools/obj2yaml/wasm2yaml.cpp | 2 +-
llvm/tools/opt/opt.cpp | 2 +-
llvm/tools/yaml2obj/yaml2obj.cpp | 6 +-
llvm/utils/split-file/split-file.cpp | 4 +-
llvm/utils/yaml-bench/YAMLBench.cpp | 2 +-
191 files changed, 590 insertions(+), 586 deletions(-)
diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
index 20ff5a5bc6e03..ccf859922e163 100644
--- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
+++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
@@ -203,7 +203,7 @@ inline bool IsObjCIdentifiedObject(const Value *V) {
StringRef Name = GV->getName();
// These special variables are known to hold values which are not
// reference-counted pointers.
- if (Name.startswith("\01l_objc_msgSend_fixup_"))
+ if (Name.starts_with("\01l_objc_msgSend_fixup_"))
return true;
StringRef Section = GV->getSection();
diff --git a/llvm/include/llvm/CodeGen/IndirectThunks.h b/llvm/include/llvm/CodeGen/IndirectThunks.h
index b0a8e3043be5c..9b064ab788bf7 100644
--- a/llvm/include/llvm/CodeGen/IndirectThunks.h
+++ b/llvm/include/llvm/CodeGen/IndirectThunks.h
@@ -48,7 +48,7 @@ template <typename Derived, typename InsertedThunksTy>
void ThunkInserter<Derived, InsertedThunksTy>::createThunkFunction(
MachineModuleInfo &MMI, StringRef Name, bool Comdat,
StringRef TargetAttrs) {
- assert(Name.startswith(getDerived().getThunkPrefix()) &&
+ assert(Name.starts_with(getDerived().getThunkPrefix()) &&
"Created a thunk with an unexpected prefix!");
Module &M = const_cast<Module &>(*MMI.getModule());
@@ -94,7 +94,7 @@ template <typename Derived, typename InsertedThunksTy>
bool ThunkInserter<Derived, InsertedThunksTy>::run(MachineModuleInfo &MMI,
MachineFunction &MF) {
// If MF is not a thunk, check to see if we need to insert a thunk.
- if (!MF.getName().startswith(getDerived().getThunkPrefix())) {
+ if (!MF.getName().starts_with(getDerived().getThunkPrefix())) {
// Only add a thunk if one of the functions has the corresponding feature
// enabled in its subtarget, and doesn't enable external thunks. The target
// can use InsertedThunks to detect whether relevant thunks have already
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index bf35febb80576..bb8dbb0478ff5 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -433,9 +433,9 @@ template <> struct ScalarTraits<FrameIndex> {
static StringRef input(StringRef Scalar, void *Ctx, FrameIndex &FI) {
FI.IsFixed = false;
StringRef Num;
- if (Scalar.startswith("%stack.")) {
+ if (Scalar.starts_with("%stack.")) {
Num = Scalar.substr(7);
- } else if (Scalar.startswith("%fixed-stack.")) {
+ } else if (Scalar.starts_with("%fixed-stack.")) {
Num = Scalar.substr(13);
FI.IsFixed = true;
} else {
diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h
index 373863e21ff02..2faf84f0372cb 100644
--- a/llvm/include/llvm/MC/MCSectionCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionCOFF.h
@@ -83,7 +83,7 @@ class MCSectionCOFF final : public MCSection {
}
static bool isImplicitlyDiscardable(StringRef Name) {
- return Name.startswith(".debug");
+ return Name.starts_with(".debug");
}
static bool classof(const MCSection *S) { return S->getVariant() == SV_COFF; }
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index 8e16fc148a3c7..761c532b9bf1f 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -742,7 +742,7 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
if (EF.getHeader().e_machine == ELF::EM_AARCH64) {
if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
StringRef Name = *NameOrErr;
- if (Name.startswith("$d") || Name.startswith("$x"))
+ if (Name.starts_with("$d") || Name.starts_with("$x"))
Result |= SymbolRef::SF_FormatSpecific;
} else {
// TODO: Actually report errors helpfully.
@@ -752,8 +752,8 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
StringRef Name = *NameOrErr;
// TODO Investigate why empty name symbols need to be marked.
- if (Name.empty() || Name.startswith("$d") || Name.startswith("$t") ||
- Name.startswith("$a"))
+ if (Name.empty() || Name.starts_with("$d") || Name.starts_with("$t") ||
+ Name.starts_with("$a"))
Result |= SymbolRef::SF_FormatSpecific;
} else {
// TODO: Actually report errors helpfully.
@@ -764,7 +764,7 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
} else if (EF.getHeader().e_machine == ELF::EM_CSKY) {
if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
StringRef Name = *NameOrErr;
- if (Name.startswith("$d") || Name.startswith("$t"))
+ if (Name.starts_with("$d") || Name.starts_with("$t"))
Result |= SymbolRef::SF_FormatSpecific;
} else {
// TODO: Actually report errors helpfully.
@@ -775,7 +775,7 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
StringRef Name = *NameOrErr;
// Mark empty name symbols (used for label differences) and mapping
// symbols.
- if (Name.empty() || Name.startswith("$d") || Name.startswith("$x"))
+ if (Name.empty() || Name.starts_with("$d") || Name.starts_with("$x"))
Result |= SymbolRef::SF_FormatSpecific;
} else {
// TODO: Actually report errors helpfully.
@@ -973,8 +973,8 @@ bool ELFObjectFile<ELFT>::isDebugSection(DataRefImpl Sec) const {
return false;
}
StringRef SectionName = SectionNameOrErr.get();
- return SectionName.startswith(".debug") ||
- SectionName.startswith(".zdebug") || SectionName == ".gdb_index";
+ return SectionName.starts_with(".debug") ||
+ SectionName.starts_with(".zdebug") || SectionName == ".gdb_index";
}
template <class ELFT>
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h
index 19ac90842bcb0..61417431f8a8f 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -720,10 +720,10 @@ template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT,
bool parseAnalysisUtilityPasses(
StringRef AnalysisName, StringRef PipelineName,
PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...> &PM) {
- if (!PipelineName.endswith(">"))
+ if (!PipelineName.ends_with(">"))
return false;
// See if this is an invalidate<> pass name
- if (PipelineName.startswith("invalidate<")) {
+ if (PipelineName.starts_with("invalidate<")) {
PipelineName = PipelineName.substr(11, PipelineName.size() - 12);
if (PipelineName != AnalysisName)
return false;
@@ -732,7 +732,7 @@ bool parseAnalysisUtilityPasses(
}
// See if this is a require<> pass name
- if (PipelineName.startswith("require<")) {
+ if (PipelineName.starts_with("require<")) {
PipelineName = PipelineName.substr(8, PipelineName.size() - 9);
if (PipelineName != AnalysisName)
return false;
diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index f001f5ee9d39b..d995cc69af894 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -548,7 +548,7 @@ class SampleContext {
assert(!ContextStr.empty());
// Note that `[]` wrapped input indicates a full context string, otherwise
// it's treated as context-less function name only.
- bool HasContext = ContextStr.startswith("[");
+ bool HasContext = ContextStr.starts_with("[");
if (!HasContext) {
State = UnknownContext;
Func = FunctionId(ContextStr);
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 97b18e51beeee..50167708163ef 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -2161,7 +2161,7 @@ struct Attributor {
Function *F = I->getFunction();
auto &ORE = Configuration.OREGetter(F);
- if (RemarkName.startswith("OMP"))
+ if (RemarkName.starts_with("OMP"))
ORE.emit([&]() {
return RemarkCB(RemarkKind(Configuration.PassName, RemarkName, I))
<< " [" << RemarkName << "]";
@@ -2181,7 +2181,7 @@ struct Attributor {
auto &ORE = Configuration.OREGetter(F);
- if (RemarkName.startswith("OMP"))
+ if (RemarkName.starts_with("OMP"))
ORE.emit([&]() {
return RemarkCB(RemarkKind(Configuration.PassName, RemarkName, F))
<< " [" << RemarkName << "]";
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 7567efbedfb02..87ddfe3e92ae9 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -1143,7 +1143,7 @@ MDNode *llvm::makePostTransformationMetadata(LLVMContext &Context,
if (S)
IsVectorMetadata =
llvm::any_of(RemovePrefixes, [S](StringRef Prefix) -> bool {
- return S->getString().startswith(Prefix);
+ return S->getString().starts_with(Prefix);
});
}
if (!IsVectorMetadata)
diff --git a/llvm/lib/Analysis/VFABIDemangling.cpp b/llvm/lib/Analysis/VFABIDemangling.cpp
index 92af314a41caa..ad918ef7245b0 100644
--- a/llvm/lib/Analysis/VFABIDemangling.cpp
+++ b/llvm/lib/Analysis/VFABIDemangling.cpp
@@ -32,7 +32,7 @@ static ParseRet tryParseISA(StringRef &MangledName, VFISAKind &ISA) {
if (MangledName.empty())
return ParseRet::Error;
- if (MangledName.startswith(VFABI::_LLVM_)) {
+ if (MangledName.starts_with(VFABI::_LLVM_)) {
MangledName = MangledName.drop_front(strlen(VFABI::_LLVM_));
ISA = VFISAKind::LLVM;
} else {
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index 919c69fe2783e..fcb25f5f1d49d 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -922,17 +922,17 @@ lltok::Kind LLLexer::LexIdentifier() {
#undef DWKEYWORD
- if (Keyword.startswith("DIFlag")) {
+ if (Keyword.starts_with("DIFlag")) {
StrVal.assign(Keyword.begin(), Keyword.end());
return lltok::DIFlag;
}
- if (Keyword.startswith("DISPFlag")) {
+ if (Keyword.starts_with("DISPFlag")) {
StrVal.assign(Keyword.begin(), Keyword.end());
return lltok::DISPFlag;
}
- if (Keyword.startswith("CSK_")) {
+ if (Keyword.starts_with("CSK_")) {
StrVal.assign(Keyword.begin(), Keyword.end());
return lltok::ChecksumKind;
}
diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp
index 420224df57df4..255937a5bdd04 100644
--- a/llvm/lib/BinaryFormat/Magic.cpp
+++ b/llvm/lib/BinaryFormat/Magic.cpp
@@ -26,7 +26,7 @@ using namespace llvm::sys::fs;
template <size_t N>
static bool startswith(StringRef Magic, const char (&S)[N]) {
- return Magic.startswith(StringRef(S, N - 1));
+ return Magic.starts_with(StringRef(S, N - 1));
}
/// Identify the magic in magic.
@@ -217,11 +217,11 @@ file_magic llvm::identify_magic(StringRef Magic) {
if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) {
uint32_t off = read32le(Magic.data() + 0x3c);
// PE/COFF file, either EXE or DLL.
- if (Magic.substr(off).startswith(
+ if (Magic.substr(off).starts_with(
StringRef(COFF::PEMagic, sizeof(COFF::PEMagic))))
return file_magic::pecoff_executable;
}
- if (Magic.startswith("Microsoft C/C++ MSF 7.00\r\n"))
+ if (Magic.starts_with("Microsoft C/C++ MSF 7.00\r\n"))
return file_magic::pdb;
if (startswith(Magic, "MDMP"))
return file_magic::minidump;
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 1a4b55ea38182..910e97489dbbe 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1633,7 +1633,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
// DICompositeType flag specifying whether template parameters are
// required on declarations of this type.
StringRef NameStr = Name->getString();
- if (!NameStr.contains('<') || NameStr.startswith("_STN|"))
+ if (!NameStr.contains('<') || NameStr.starts_with("_STN|"))
TemplateParams = getMDOrNull(Record[14]);
}
} else {
diff --git a/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp b/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
index 96662378a8693..15b6f63e86327 100644
--- a/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
+++ b/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
@@ -302,7 +302,7 @@ Error BasicBlockSectionsProfileReader::ReadV0Profile() {
// specifier starting with `M=`.
auto [AliasesStr, DIFilenameStr] = S.split(' ');
SmallString<128> DIFilename;
- if (DIFilenameStr.startswith("M=")) {
+ if (DIFilenameStr.starts_with("M=")) {
DIFilename =
sys::path::remove_leading_dotslash(DIFilenameStr.substr(2));
if (DIFilename.empty())
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 339019923c00b..ab4b26e294106 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -643,8 +643,8 @@ bool GlobalMerge::doInitialization(Module &M) {
StringRef Section = GV.getSection();
// Ignore all 'special' globals.
- if (GV.getName().startswith("llvm.") ||
- GV.getName().startswith(".llvm."))
+ if (GV.getName().starts_with("llvm.") ||
+ GV.getName().starts_with(".llvm."))
continue;
// Ignore all "required" globals:
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index 0a0e386cde610..870611248466f 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -300,8 +300,8 @@ static Cursor maybeLexIdentifier(Cursor C, MIToken &Token) {
static Cursor maybeLexMachineBasicBlock(Cursor C, MIToken &Token,
ErrorCallbackType ErrorCallback) {
- bool IsReference = C.remaining().startswith("%bb.");
- if (!IsReference && !C.remaining().startswith("bb."))
+ bool IsReference = C.remaining().starts_with("%bb.");
+ if (!IsReference && !C.remaining().starts_with("bb."))
return std::nullopt;
auto Range = C;
unsigned PrefixLength = IsReference ? 4 : 3;
@@ -335,7 +335,7 @@ static Cursor maybeLexMachineBasicBlock(Cursor C, MIToken &Token,
static Cursor maybeLexIndex(Cursor C, MIToken &Token, StringRef Rule,
MIToken::TokenKind Kind) {
- if (!C.remaining().startswith(Rule) || !isdigit(C.peek(Rule.size())))
+ if (!C.remaining().starts_with(Rule) || !isdigit(C.peek(Rule.size())))
return std::nullopt;
auto Range = C;
C.advance(Rule.size());
@@ -348,7 +348,7 @@ static Cursor maybeLexIndex(Cursor C, MIToken &Token, StringRef Rule,
static Cursor maybeLexIndexAndName(Cursor C, MIToken &Token, StringRef Rule,
MIToken::TokenKind Kind) {
- if (!C.remaining().startswith(Rule) || !isdigit(C.peek(Rule.size())))
+ if (!C.remaining().starts_with(Rule) || !isdigit(C.peek(Rule.size())))
return std::nullopt;
auto Range = C;
C.advance(Rule.size());
@@ -388,7 +388,7 @@ static Cursor maybeLexConstantPoolItem(Cursor C, MIToken &Token) {
static Cursor maybeLexSubRegisterIndex(Cursor C, MIToken &Token,
ErrorCallbackType ErrorCallback) {
const StringRef Rule = "%subreg.";
- if (!C.remaining().startswith(Rule))
+ if (!C.remaining().starts_with(Rule))
return std::nullopt;
return lexName(C, Token, MIToken::SubRegisterIndex, Rule.size(),
ErrorCallback);
@@ -397,7 +397,7 @@ static Cursor maybeLexSubRegisterIndex(Cursor C, MIToken &Token,
static Cursor maybeLexIRBlock(Cursor C, MIToken &Token,
ErrorCallbackType ErrorCallback) {
const StringRef Rule = "%ir-block.";
- if (!C.remaining().startswith(Rule))
+ if (!C.remaining().starts_with(Rule))
return std::nullopt;
if (isdigit(C.peek(Rule.size())))
return maybeLexIndex(C, Token, Rule, MIToken::IRBlock);
@@ -407,7 +407,7 @@ static Cursor maybeLexIRBlock(Cursor C, MIToken &Token,
static Cursor maybeLexIRValue(Cursor C, MIToken &Token,
ErrorCallbackType ErrorCallback) {
const StringRef Rule = "%ir.";
- if (!C.remaining().startswith(Rule))
+ if (!C.remaining().starts_with(Rule))
return std::nullopt;
if (isdigit(C.peek(Rule.size())))
return maybeLexIndex(C, Token, Rule, MIToken::IRValue);
@@ -501,7 +501,7 @@ static Cursor maybeLexExternalSymbol(Cursor C, MIToken &Token,
static Cursor maybeLexMCSymbol(Cursor C, MIToken &Token,
ErrorCallbackType ErrorCallback) {
const StringRef Rule = "<mcsymbol ";
- if (!C.remaining().startswith(Rule))
+ if (!C.remaining().starts_with(Rule))
return std::nullopt;
auto Start = C;
C.advance(Rule.size());
diff --git a/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp b/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
index cc29bdce1210f..9002a70768401 100644
--- a/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
+++ b/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
@@ -52,7 +52,7 @@ bool MachineSanitizerBinaryMetadata::runOnMachineFunction(MachineFunction &MF) {
if (!MD)
return false;
const auto &Section = *cast<MDString>(MD->getOperand(0));
- if (!Section.getString().startswith(kSanitizerBinaryMetadataCoveredSection))
+ if (!Section.getString().starts_with(kSanitizerBinaryMetadataCoveredSection))
return false;
auto &AuxMDs = *cast<MDTuple>(MD->getOperand(1));
// Assume it currently only has features.
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 9827bd3ff4f1b..c71ba4d71efaf 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -479,25 +479,25 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind 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.starts_with(".bss.") ||
+ Name.starts_with(".gnu.linkonce.b.") ||
+ Name.starts_with(".llvm.linkonce.b.") ||
Name == ".sbss" ||
- Name.startswith(".sbss.") ||
- Name.startswith(".gnu.linkonce.sb.") ||
- Name.startswith(".llvm.linkonce.sb."))
+ 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."))
+ 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."))
+ Name.starts_with(".tbss.") ||
+ Name.starts_with(".gnu.linkonce.tb.") ||
+ Name.starts_with(".llvm.linkonce.tb."))
return SectionKind::getThreadBSS();
return K;
@@ -512,7 +512,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 +752,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 +1036,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) {
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 347bada6f69d5..68e49267987a1 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -324,7 +324,7 @@ void llvm::calculateSEHStateForAsynchEH(const BasicBlock *BB, int State,
const Constant *FilterOrNull = cast<Constant>(
cast<CatchPadInst>(I)->getArgOperand(0)->stripPointerCasts());
const Function *Filter = dyn_cast<Function>(FilterOrNull);
- if (!Filter || !Filter->getName().startswith("__IsLocalUnwind"))
+ if (!Filter || !Filter->getName().starts_with("__IsLocalUnwind"))
State = EHInfo.SEHUnwindMap[State].ToState; // Retrive next State
} else if ((isa<CleanupReturnInst>(TI) || isa<CatchReturnInst>(TI)) &&
State > 0) {
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 1a7ea47adc5ca..10967123a562e 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -204,18 +204,18 @@ static void analyzeImportedModule(
return;
StringRef Path = dwarf::toStringRef(DIE.find(dwarf::DW_AT_LLVM_include_path));
- if (!Path.endswith(".swiftinterface"))
+ if (!Path.ends_with(".swiftinterface"))
return;
// Don't track interfaces that are part of the SDK.
StringRef SysRoot = dwarf::toStringRef(DIE.find(dwarf::DW_AT_LLVM_sysroot));
if (SysRoot.empty())
SysRoot = CU.getSysRoot();
- if (!SysRoot.empty() && Path.startswith(SysRoot))
+ if (!SysRoot.empty() && Path.starts_with(SysRoot))
return;
// Don't track interfaces that are part of the toolchain.
// For example: Swift, _Concurrency, ...
SmallString<128> Toolchain = guessToolchainBaseDir(SysRoot);
- if (!Toolchain.empty() && Path.startswith(Toolchain))
+ if (!Toolchain.empty() && Path.starts_with(Toolchain))
return;
std::optional<const char *> Name =
dwarf::toString(DIE.find(dwarf::DW_AT_name));
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp
index 48e7cb1fd7e2f..3f0e756902727 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp
@@ -271,19 +271,19 @@ void CompileUnit::analyzeImportedModule(const DWARFDebugInfoEntry *DieEntry) {
StringRef Path =
dwarf::toStringRef(find(DieEntry, dwarf::DW_AT_LLVM_include_path));
- if (!Path.endswith(".swiftinterface"))
+ if (!Path.ends_with(".swiftinterface"))
return;
// Don't track interfaces that are part of the SDK.
StringRef SysRoot =
dwarf::toStringRef(find(DieEntry, dwarf::DW_AT_LLVM_sysroot));
if (SysRoot.empty())
SysRoot = getSysRoot();
- if (!SysRoot.empty() && Path.startswith(SysRoot))
+ if (!SysRoot.empty() && Path.starts_with(SysRoot))
return;
// Don't track interfaces that are part of the toolchain.
// For example: Swift, _Concurrency, ...
SmallString<128> Toolchain = guessToolchainBaseDir(SysRoot);
- if (!Toolchain.empty() && Path.startswith(Toolchain))
+ if (!Toolchain.empty() && Path.starts_with(Toolchain))
return;
if (std::optional<DWARFFormValue> Val = find(DieEntry, dwarf::DW_AT_name)) {
Expected<const char *> Name = Val->getAsCString();
diff --git a/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp b/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp
index e0900f7a8e3d3..a9b4478e33c40 100644
--- a/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp
+++ b/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp
@@ -333,7 +333,7 @@ Error SyntheticTypeNameBuilder::addTypeName(UnitEntryPairTy InputUnitEntryPair,
HasShortName = true;
HasTemplatesInShortName =
- Name.endswith(">") && Name.count("<") != 0 && !Name.endswith("<=>");
+ Name.ends_with(">") && Name.count("<") != 0 && !Name.ends_with("<=>");
} else {
// Finally check for declaration attributes.
addDieNameFromDeclFileAndDeclLine(InputUnitEntryPair, HasDeclFileName);
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 46f8064bb1686..a1fe9c5fcd733 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -349,11 +349,11 @@ identifyELFSectionStartAndEndSymbols(LinkGraph &G, Symbol &Sym) {
constexpr StringRef EndSymbolPrefix = "__end";
auto SymName = Sym.getName();
- if (SymName.startswith(StartSymbolPrefix)) {
+ if (SymName.starts_with(StartSymbolPrefix)) {
if (auto *Sec =
G.findSectionByName(SymName.drop_front(StartSymbolPrefix.size())))
return {*Sec, true};
- } else if (SymName.startswith(EndSymbolPrefix)) {
+ } else if (SymName.starts_with(EndSymbolPrefix)) {
if (auto *Sec =
G.findSectionByName(SymName.drop_front(EndSymbolPrefix.size())))
return {*Sec, false};
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
index bcbc429cae127..bb21f633d9829 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
@@ -73,7 +73,7 @@ Linkage MachOLinkGraphBuilder::getLinkage(uint16_t Desc) {
Scope MachOLinkGraphBuilder::getScope(StringRef Name, uint8_t Type) {
if (Type & MachO::N_EXT) {
- if ((Type & MachO::N_PEXT) || Name.startswith("l"))
+ if ((Type & MachO::N_PEXT) || Name.starts_with("l"))
return Scope::Hidden;
else
return Scope::Default;
diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp
index b541db3672f4e..f65ec27ff8756 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp
@@ -105,7 +105,7 @@ llvm::orc::createDWARFContext(LinkGraph &G) {
auto SecData = getSectionData(Sec);
auto Name = Sec.getName();
// DWARFContext expects the section name to not start with a dot
- if (Name.startswith("."))
+ if (Name.starts_with("."))
Name = Name.drop_front();
LLVM_DEBUG(dbgs() << "Creating DWARFContext section " << Name
<< " with size " << SecData.size() << "\n");
diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
index c6ffd9f7c2e3c..e387b06ee9346 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
@@ -34,7 +34,7 @@ class MachODebugObjectSynthesizerBase
: public GDBJITDebugInfoRegistrationPlugin::DebugSectionSynthesizer {
public:
static bool isDebugSection(Section &Sec) {
- return Sec.getName().startswith("__DWARF,");
+ return Sec.getName().starts_with("__DWARF,");
}
MachODebugObjectSynthesizerBase(LinkGraph &G, ExecutorAddr RegisterActionAddr)
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index 7316b2dce8abb..8d5608cc4d4cf 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -103,8 +103,8 @@ bool StaticInitGVIterator::isStaticInitGlobal(GlobalValue &GV) {
// FIXME: These section checks are too strict: We should match first and
// second word split by comma.
if (GV.hasSection() &&
- (GV.getSection().startswith("__DATA,__objc_classlist") ||
- GV.getSection().startswith("__DATA,__objc_selrefs")))
+ (GV.getSection().starts_with("__DATA,__objc_classlist") ||
+ GV.getSection().starts_with("__DATA,__objc_selrefs")))
return true;
}
@@ -503,7 +503,7 @@ Error DLLImportDefinitionGenerator::tryToGenerate(
DenseMap<StringRef, SymbolLookupFlags> ToLookUpSymbols;
for (auto &KV : Symbols) {
StringRef Deinterned = *KV.first;
- if (Deinterned.startswith(getImpPrefix()))
+ if (Deinterned.starts_with(getImpPrefix()))
Deinterned = Deinterned.drop_front(StringRef(getImpPrefix()).size());
// Don't degrade the required state
if (ToLookUpSymbols.count(Deinterned) &&
diff --git a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
index adf38659de3d3..f9efff148df9c 100644
--- a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
@@ -285,7 +285,7 @@ std::vector<GlobalValue *> SymbolLinkagePromoter::operator()(Module &M) {
// Rename if necessary.
if (!GV.hasName())
GV.setName("__orc_anon." + Twine(NextId++));
- else if (GV.getName().startswith("\01L"))
+ else if (GV.getName().starts_with("\01L"))
GV.setName("__" + GV.getName().substr(1) + "." + Twine(NextId++));
else if (GV.hasLocalLinkage())
GV.setName("__orc_lcl." + GV.getName() + "." + Twine(NextId++));
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 90123b3f0a965..d8d03a0a62ca2 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -272,11 +272,11 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
// will trigger a lookup to materialize the module) and the InitFunctions
// map (which holds the names of the symbols to execute).
for (auto &KV : MU.getSymbols())
- if ((*KV.first).startswith(InitFunctionPrefix)) {
+ if ((*KV.first).starts_with(InitFunctionPrefix)) {
InitSymbols[&JD].add(KV.first,
SymbolLookupFlags::WeaklyReferencedSymbol);
InitFunctions[&JD].add(KV.first);
- } else if ((*KV.first).startswith(DeInitFunctionPrefix)) {
+ } else if ((*KV.first).starts_with(DeInitFunctionPrefix)) {
DeInitFunctions[&JD].add(KV.first);
}
}
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
index 7c8fa63477d00..0286b0c931974 100644
--- a/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
@@ -72,7 +72,7 @@ getMachOObjectFileSymbolInfo(ExecutionSession &ES,
return SymFlags.takeError();
// Strip the 'exported' flag from MachO linker-private symbols.
- if (Name->startswith("l"))
+ if (Name->starts_with("l"))
*SymFlags &= ~JITSymbolFlags::Exported;
I.SymbolFlags[ES.intern(*Name)] = std::move(*SymFlags);
diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
index 1d9d23e641587..a407fcab6ae3e 100644
--- a/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
@@ -102,7 +102,7 @@ bool isELFInitializerSection(StringRef SecName) {
}
bool isCOFFInitializerSection(StringRef SecName) {
- return SecName.startswith(".CRT");
+ return SecName.starts_with(".CRT");
}
} // namespace orc
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
index 210fbf6e43e35..c153b4464568b 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
@@ -42,7 +42,7 @@ JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
const auto &DL = M->getDataLayout();
StringRef LPGP = DL.getLinkerPrivateGlobalPrefix();
if (!LPGP.empty() && GV.getName().front() == '\01' &&
- GV.getName().substr(1).startswith(LPGP))
+ GV.getName().substr(1).starts_with(LPGP))
Flags &= ~JITSymbolFlags::Exported;
}
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
index 9255311f992d0..25a2d8780fb56 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
@@ -83,7 +83,8 @@ uint64_t RuntimeDyldCOFF::getDLLImportOffset(unsigned SectionID, StubMap &Stubs,
StringRef Name,
bool SetSectionIDMinus1) {
LLVM_DEBUG(dbgs() << "Getting DLLImport entry for " << Name << "... ");
- assert(Name.startswith(getImportSymbolPrefix()) && "Not a DLLImport symbol?");
+ assert(Name.starts_with(getImportSymbolPrefix()) &&
+ "Not a DLLImport symbol?");
RelocationValueRef Reloc;
Reloc.SymbolName = Name.data();
auto I = Stubs.find(Reloc);
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index 68497305f06b7..7fadbdd6a1fff 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@ -142,7 +142,7 @@ class RuntimeDyldCheckerExprEval {
std::tie(Token, Remaining) = parseNumberString(Expr);
else {
unsigned TokLen = 1;
- if (Expr.startswith("<<") || Expr.startswith(">>"))
+ if (Expr.starts_with("<<") || Expr.starts_with(">>"))
TokLen = 2;
Token = Expr.substr(0, TokLen);
}
@@ -177,9 +177,9 @@ class RuntimeDyldCheckerExprEval {
return std::make_pair(BinOpToken::Invalid, "");
// Handle the two 2-character tokens.
- if (Expr.startswith("<<"))
+ if (Expr.starts_with("<<"))
return std::make_pair(BinOpToken::ShiftLeft, Expr.substr(2).ltrim());
- if (Expr.startswith(">>"))
+ if (Expr.starts_with(">>"))
return std::make_pair(BinOpToken::ShiftRight, Expr.substr(2).ltrim());
// Handle one-character tokens.
@@ -242,7 +242,7 @@ class RuntimeDyldCheckerExprEval {
// On success, returns a pair containing the value of the operand, plus
// the expression remaining to be evaluated.
std::pair<EvalResult, StringRef> evalDecodeOperand(StringRef Expr) const {
- if (!Expr.startswith("("))
+ if (!Expr.starts_with("("))
return std::make_pair(unexpectedToken(Expr, Expr, "expected '('"), "");
StringRef RemainingExpr = Expr.substr(1).ltrim();
StringRef Symbol;
@@ -273,7 +273,7 @@ class RuntimeDyldCheckerExprEval {
"");
}
- if (!RemainingExpr.startswith(","))
+ if (!RemainingExpr.starts_with(","))
return std::make_pair(
unexpectedToken(RemainingExpr, RemainingExpr, "expected ','"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -283,7 +283,7 @@ class RuntimeDyldCheckerExprEval {
if (OpIdxExpr.hasError())
return std::make_pair(OpIdxExpr, "");
- if (!RemainingExpr.startswith(")"))
+ if (!RemainingExpr.starts_with(")"))
return std::make_pair(
unexpectedToken(RemainingExpr, RemainingExpr, "expected ')'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -343,7 +343,7 @@ class RuntimeDyldCheckerExprEval {
// expression remaining to be evaluated.
std::pair<EvalResult, StringRef> evalNextPC(StringRef Expr,
ParseContext PCtx) const {
- if (!Expr.startswith("("))
+ if (!Expr.starts_with("("))
return std::make_pair(unexpectedToken(Expr, Expr, "expected '('"), "");
StringRef RemainingExpr = Expr.substr(1).ltrim();
StringRef Symbol;
@@ -354,7 +354,7 @@ class RuntimeDyldCheckerExprEval {
EvalResult(("Cannot decode unknown symbol '" + Symbol + "'").str()),
"");
- if (!RemainingExpr.startswith(")"))
+ if (!RemainingExpr.starts_with(")"))
return std::make_pair(
unexpectedToken(RemainingExpr, RemainingExpr, "expected ')'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -381,7 +381,7 @@ class RuntimeDyldCheckerExprEval {
// remaining to be evaluated.
std::pair<EvalResult, StringRef>
evalStubOrGOTAddr(StringRef Expr, ParseContext PCtx, bool IsStubAddr) const {
- if (!Expr.startswith("("))
+ if (!Expr.starts_with("("))
return std::make_pair(unexpectedToken(Expr, Expr, "expected '('"), "");
StringRef RemainingExpr = Expr.substr(1).ltrim();
@@ -392,7 +392,7 @@ class RuntimeDyldCheckerExprEval {
StubContainerName = RemainingExpr.substr(0, ComaIdx).rtrim();
RemainingExpr = RemainingExpr.substr(ComaIdx).ltrim();
- if (!RemainingExpr.startswith(","))
+ if (!RemainingExpr.starts_with(","))
return std::make_pair(
unexpectedToken(RemainingExpr, Expr, "expected ','"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -400,7 +400,7 @@ class RuntimeDyldCheckerExprEval {
StringRef Symbol;
std::tie(Symbol, RemainingExpr) = parseSymbol(RemainingExpr);
- if (!RemainingExpr.startswith(")"))
+ if (!RemainingExpr.starts_with(")"))
return std::make_pair(
unexpectedToken(RemainingExpr, Expr, "expected ')'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -418,7 +418,7 @@ class RuntimeDyldCheckerExprEval {
std::pair<EvalResult, StringRef> evalSectionAddr(StringRef Expr,
ParseContext PCtx) const {
- if (!Expr.startswith("("))
+ if (!Expr.starts_with("("))
return std::make_pair(unexpectedToken(Expr, Expr, "expected '('"), "");
StringRef RemainingExpr = Expr.substr(1).ltrim();
@@ -429,7 +429,7 @@ class RuntimeDyldCheckerExprEval {
FileName = RemainingExpr.substr(0, ComaIdx).rtrim();
RemainingExpr = RemainingExpr.substr(ComaIdx).ltrim();
- if (!RemainingExpr.startswith(","))
+ if (!RemainingExpr.starts_with(","))
return std::make_pair(
unexpectedToken(RemainingExpr, Expr, "expected ','"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -439,7 +439,7 @@ class RuntimeDyldCheckerExprEval {
SectionName = RemainingExpr.substr(0, CloseParensIdx).rtrim();
RemainingExpr = RemainingExpr.substr(CloseParensIdx).ltrim();
- if (!RemainingExpr.startswith(")"))
+ if (!RemainingExpr.starts_with(")"))
return std::make_pair(
unexpectedToken(RemainingExpr, Expr, "expected ')'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -480,7 +480,7 @@ class RuntimeDyldCheckerExprEval {
std::string ErrMsg("No known address for symbol '");
ErrMsg += Symbol;
ErrMsg += "'";
- if (Symbol.startswith("L"))
+ if (Symbol.starts_with("L"))
ErrMsg += " (this appears to be an assembler local label - "
" perhaps drop the 'L'?)";
@@ -501,7 +501,7 @@ class RuntimeDyldCheckerExprEval {
// pair representing the number and the expression remaining to be parsed.
std::pair<StringRef, StringRef> parseNumberString(StringRef Expr) const {
size_t FirstNonDigit = StringRef::npos;
- if (Expr.startswith("0x")) {
+ if (Expr.starts_with("0x")) {
FirstNonDigit = Expr.find_first_not_of("0123456789abcdefABCDEF", 2);
if (FirstNonDigit == StringRef::npos)
FirstNonDigit = Expr.size();
@@ -535,14 +535,14 @@ class RuntimeDyldCheckerExprEval {
// remaining to be parsed.
std::pair<EvalResult, StringRef> evalParensExpr(StringRef Expr,
ParseContext PCtx) const {
- assert(Expr.startswith("(") && "Not a parenthesized expression");
+ assert(Expr.starts_with("(") && "Not a parenthesized expression");
EvalResult SubExprResult;
StringRef RemainingExpr;
std::tie(SubExprResult, RemainingExpr) =
evalComplexExpr(evalSimpleExpr(Expr.substr(1).ltrim(), PCtx), PCtx);
if (SubExprResult.hasError())
return std::make_pair(SubExprResult, "");
- if (!RemainingExpr.startswith(")"))
+ if (!RemainingExpr.starts_with(")"))
return std::make_pair(
unexpectedToken(RemainingExpr, Expr, "expected ')'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -554,11 +554,11 @@ class RuntimeDyldCheckerExprEval {
// Return a pair containing the result, plus the expression remaining to be
// parsed.
std::pair<EvalResult, StringRef> evalLoadExpr(StringRef Expr) const {
- assert(Expr.startswith("*") && "Not a load expression");
+ assert(Expr.starts_with("*") && "Not a load expression");
StringRef RemainingExpr = Expr.substr(1).ltrim();
// Parse read size.
- if (!RemainingExpr.startswith("{"))
+ if (!RemainingExpr.starts_with("{"))
return std::make_pair(EvalResult("Expected '{' following '*'."), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
EvalResult ReadSizeExpr;
@@ -568,7 +568,7 @@ class RuntimeDyldCheckerExprEval {
uint64_t ReadSize = ReadSizeExpr.getValue();
if (ReadSize < 1 || ReadSize > 8)
return std::make_pair(EvalResult("Invalid size for dereference."), "");
- if (!RemainingExpr.startswith("}"))
+ if (!RemainingExpr.starts_with("}"))
return std::make_pair(EvalResult("Missing '}' for dereference."), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -625,7 +625,7 @@ class RuntimeDyldCheckerExprEval {
return std::make_pair(SubExprResult, RemainingExpr);
// Evaluate bit-slice if present.
- if (RemainingExpr.startswith("["))
+ if (RemainingExpr.starts_with("["))
std::tie(SubExprResult, RemainingExpr) =
evalSliceExpr(std::make_pair(SubExprResult, RemainingExpr));
@@ -645,7 +645,7 @@ class RuntimeDyldCheckerExprEval {
StringRef RemainingExpr;
std::tie(SubExprResult, RemainingExpr) = Ctx;
- assert(RemainingExpr.startswith("[") && "Not a slice expr.");
+ assert(RemainingExpr.starts_with("[") && "Not a slice expr.");
RemainingExpr = RemainingExpr.substr(1).ltrim();
EvalResult HighBitExpr;
@@ -654,7 +654,7 @@ class RuntimeDyldCheckerExprEval {
if (HighBitExpr.hasError())
return std::make_pair(HighBitExpr, RemainingExpr);
- if (!RemainingExpr.startswith(":"))
+ if (!RemainingExpr.starts_with(":"))
return std::make_pair(
unexpectedToken(RemainingExpr, RemainingExpr, "expected ':'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -665,7 +665,7 @@ class RuntimeDyldCheckerExprEval {
if (LowBitExpr.hasError())
return std::make_pair(LowBitExpr, RemainingExpr);
- if (!RemainingExpr.startswith("]"))
+ if (!RemainingExpr.starts_with("]"))
return std::make_pair(
unexpectedToken(RemainingExpr, RemainingExpr, "expected ']'"), "");
RemainingExpr = RemainingExpr.substr(1).ltrim();
@@ -846,7 +846,7 @@ bool RuntimeDyldCheckerImpl::checkAllRulesInBuffer(StringRef RulePrefix,
++LineEnd;
StringRef Line(LineStart, LineEnd - LineStart);
- if (Line.startswith(RulePrefix))
+ if (Line.starts_with(RulePrefix))
CheckExpr += Line.substr(RulePrefix.size()).str();
// If there's a check expr string...
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFAArch64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFAArch64.h
index a1151b81d141e..66c9753a72fda 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFAArch64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFAArch64.h
@@ -174,7 +174,7 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
unsigned TargetSectionID = -1;
uint64_t TargetOffset = -1;
- if (TargetName.startswith(getImportSymbolPrefix())) {
+ if (TargetName.starts_with(getImportSymbolPrefix())) {
TargetSectionID = SectionID;
TargetOffset = getDLLImportOffset(SectionID, Stubs, TargetName);
TargetName = StringRef();
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
index 2a54728fd0bf3..0d5afc289b8c5 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
@@ -60,7 +60,7 @@ class RuntimeDyldCOFFI386 : public RuntimeDyldCOFF {
unsigned TargetSectionID = -1;
uint64_t TargetOffset = -1;
- if (TargetName.startswith(getImportSymbolPrefix())) {
+ if (TargetName.starts_with(getImportSymbolPrefix())) {
TargetSectionID = SectionID;
TargetOffset = getDLLImportOffset(SectionID, Stubs, TargetName, true);
TargetName = StringRef();
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
index a3e66c6bc0ecd..c079d8896c1d7 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
@@ -129,7 +129,7 @@ class RuntimeDyldCOFFThumb : public RuntimeDyldCOFF {
unsigned TargetSectionID = -1;
uint64_t TargetOffset = -1;
- if (TargetName.startswith(getImportSymbolPrefix())) {
+ if (TargetName.starts_with(getImportSymbolPrefix())) {
TargetSectionID = SectionID;
TargetOffset = getDLLImportOffset(SectionID, Stubs, TargetName, true);
TargetName = StringRef();
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
index 43ce64af86852..984a8d765c845 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -226,7 +226,7 @@ class RuntimeDyldCOFFX86_64 : public RuntimeDyldCOFF {
unsigned TargetSectionID = 0;
uint64_t TargetOffset = 0;
- if (TargetName.startswith(getImportSymbolPrefix())) {
+ if (TargetName.starts_with(getImportSymbolPrefix())) {
assert(IsExtern && "DLLImport not marked extern?");
TargetSectionID = SectionID;
TargetOffset = getDLLImportOffset(SectionID, Stubs, TargetName);
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index ac8f52d586bc3..b728c14d288aa 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -404,7 +404,7 @@ Expected<std::unique_ptr<ExpressionAST>> Pattern::parseNumericOperand(
StringRef &Expr, AllowedOperand AO, bool MaybeInvalidConstraint,
std::optional<size_t> LineNumber, FileCheckPatternContext *Context,
const SourceMgr &SM) {
- if (Expr.startswith("(")) {
+ if (Expr.starts_with("(")) {
if (AO != AllowedOperand::Any)
return ErrorDiagnostic::get(
SM, Expr, "parenthesized expression not permitted here");
@@ -417,7 +417,7 @@ Expected<std::unique_ptr<ExpressionAST>> Pattern::parseNumericOperand(
parseVariable(Expr, SM);
if (ParseVarResult) {
// Try to parse a function call.
- if (Expr.ltrim(SpaceChars).startswith("(")) {
+ if (Expr.ltrim(SpaceChars).starts_with("(")) {
if (AO != AllowedOperand::Any)
return ErrorDiagnostic::get(SM, ParseVarResult->Name,
"unexpected function call");
@@ -458,7 +458,7 @@ Expected<std::unique_ptr<ExpressionAST>>
Pattern::parseParenExpr(StringRef &Expr, std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) {
Expr = Expr.ltrim(SpaceChars);
- assert(Expr.startswith("("));
+ assert(Expr.starts_with("("));
// Parse right operand.
Expr.consume_front("(");
@@ -471,7 +471,7 @@ Pattern::parseParenExpr(StringRef &Expr, std::optional<size_t> LineNumber,
Expr, AllowedOperand::Any, /*MaybeInvalidConstraint=*/false, LineNumber,
Context, SM);
Expr = Expr.ltrim(SpaceChars);
- while (SubExprResult && !Expr.empty() && !Expr.startswith(")")) {
+ while (SubExprResult && !Expr.empty() && !Expr.starts_with(")")) {
StringRef OrigExpr = Expr;
SubExprResult = parseBinop(OrigExpr, Expr, std::move(*SubExprResult), false,
LineNumber, Context, SM);
@@ -537,7 +537,7 @@ Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName,
std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) {
Expr = Expr.ltrim(SpaceChars);
- assert(Expr.startswith("("));
+ assert(Expr.starts_with("("));
auto OptFunc = StringSwitch<binop_eval_t>(FuncName)
.Case("add", exprAdd)
@@ -557,8 +557,8 @@ Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName,
// Parse call arguments, which are comma separated.
SmallVector<std::unique_ptr<ExpressionAST>, 4> Args;
- while (!Expr.empty() && !Expr.startswith(")")) {
- if (Expr.startswith(","))
+ while (!Expr.empty() && !Expr.starts_with(")")) {
+ if (Expr.starts_with(","))
return ErrorDiagnostic::get(SM, Expr, "missing argument");
// Parse the argument, which is an arbitary expression.
@@ -569,7 +569,7 @@ Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName,
while (Arg && !Expr.empty()) {
Expr = Expr.ltrim(SpaceChars);
// Have we reached an argument terminator?
- if (Expr.startswith(",") || Expr.startswith(")"))
+ if (Expr.starts_with(",") || Expr.starts_with(")"))
break;
// Arg = Arg <op> <expr>
@@ -588,7 +588,7 @@ Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName,
break;
Expr = Expr.ltrim(SpaceChars);
- if (Expr.startswith(")"))
+ if (Expr.starts_with(")"))
return ErrorDiagnostic::get(SM, Expr, "missing argument");
}
@@ -818,7 +818,7 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
// by escaping scary characters in fixed strings, building up one big regex.
while (!PatternStr.empty()) {
// RegEx matches.
- if (PatternStr.startswith("{{")) {
+ if (PatternStr.starts_with("{{")) {
// This is the start of a regex match. Scan for the }}.
size_t End = PatternStr.find("}}");
if (End == StringRef::npos) {
@@ -857,7 +857,7 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
// names must satisfy the regular expression "[a-zA-Z_][0-9a-zA-Z_]*" to be
// valid, as this helps catch some common errors. If there are extra '['s
// before the "[[", treat them literally.
- if (PatternStr.startswith("[[") && !PatternStr.startswith("[[[")) {
+ if (PatternStr.starts_with("[[") && !PatternStr.starts_with("[[[")) {
StringRef UnparsedPatternStr = PatternStr.substr(2);
// Find the closing bracket pair ending the match. End is going to be an
// offset relative to the beginning of the match string.
@@ -1392,7 +1392,7 @@ size_t Pattern::FindRegexVarEnd(StringRef Str, SourceMgr &SM) {
size_t BracketDepth = 0;
while (!Str.empty()) {
- if (Str.startswith("]]") && BracketDepth == 0)
+ if (Str.starts_with("]]") && BracketDepth == 0)
return Offset;
if (Str[0] == '\\') {
// Backslash escapes the next char within regexes, so skip them both.
@@ -1591,10 +1591,10 @@ FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix,
}
// You can't combine -NOT with another suffix.
- if (Rest.startswith("DAG-NOT:") || Rest.startswith("NOT-DAG:") ||
- Rest.startswith("NEXT-NOT:") || Rest.startswith("NOT-NEXT:") ||
- Rest.startswith("SAME-NOT:") || Rest.startswith("NOT-SAME:") ||
- Rest.startswith("EMPTY-NOT:") || Rest.startswith("NOT-EMPTY:"))
+ if (Rest.starts_with("DAG-NOT:") || Rest.starts_with("NOT-DAG:") ||
+ Rest.starts_with("NEXT-NOT:") || Rest.starts_with("NOT-NEXT:") ||
+ Rest.starts_with("SAME-NOT:") || Rest.starts_with("NOT-SAME:") ||
+ Rest.starts_with("EMPTY-NOT:") || Rest.starts_with("NOT-EMPTY:"))
return {Check::CheckBadNot, Rest};
if (Rest.consume_front("NEXT"))
diff --git a/llvm/lib/FuzzMutate/FuzzerCLI.cpp b/llvm/lib/FuzzMutate/FuzzerCLI.cpp
index 0e47e3cc3af25..c64e9c04e199b 100644
--- a/llvm/lib/FuzzMutate/FuzzerCLI.cpp
+++ b/llvm/lib/FuzzMutate/FuzzerCLI.cpp
@@ -43,7 +43,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
Args.push_back("-global-isel");
// For now we default GlobalISel to -O0
Args.push_back("-O0");
- } else if (Opt.startswith("O")) {
+ } else if (Opt.starts_with("O")) {
Args.push_back("-" + Opt.str());
} else if (Triple(Opt).getArch()) {
Args.push_back("-mtriple=" + Opt.str());
@@ -140,7 +140,7 @@ int llvm::runFuzzerOnInputs(int ArgC, char *ArgV[], FuzzerTestFun TestOne,
for (int I = 1; I < ArgC; ++I) {
StringRef Arg(ArgV[I]);
- if (Arg.startswith("-")) {
+ if (Arg.starts_with("-")) {
if (Arg.equals("-ignore_remaining_args=1"))
break;
continue;
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 645691f441794..eeac80c013a1f 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -582,7 +582,7 @@ static bool UpgradeX86IntrinsicFunction(Function *F, StringRef Name,
if (Name.consume_front("xop.")) {
Intrinsic::ID ID = Intrinsic::not_intrinsic;
- if (Name.startswith("vpermil2")) { // Added in 3.9
+ if (Name.starts_with("vpermil2")) { // Added in 3.9
// Upgrade any XOP PERMIL2 index operand still using a float/double
// vector.
auto Idx = F->getFunctionType()->getParamType(2);
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 3fe940e19295b..d532aead90be7 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -559,7 +559,7 @@ bool llvm::StripDebugInfo(Module &M) {
for (NamedMDNode &NMD : llvm::make_early_inc_range(M.named_metadata())) {
// We're stripping debug info, and without them, coverage information
// doesn't quite make sense.
- if (NMD.getName().startswith("llvm.dbg.") ||
+ if (NMD.getName().starts_with("llvm.dbg.") ||
NMD.getName() == "llvm.gcov") {
NMD.eraseFromParent();
Changed = true;
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index c3706dc1b02fc..22e2455462bf4 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -439,7 +439,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
if (ParentModule)
ParentModule->getFunctionList().push_back(this);
- HasLLVMReservedName = getName().startswith("llvm.");
+ HasLLVMReservedName = getName().starts_with("llvm.");
// Ensure intrinsics have the right parameter attributes.
// Note, the IntID field will have been set in Value::setName if this function
// name is a valid intrinsic ID.
@@ -876,7 +876,7 @@ bool Function::isTargetIntrinsic() const {
///
/// Returns the relevant slice of \c IntrinsicNameTable
static ArrayRef<const char *> findTargetSubtable(StringRef Name) {
- assert(Name.startswith("llvm."));
+ assert(Name.starts_with("llvm."));
ArrayRef<IntrinsicTargetInfo> Targets(TargetInfos);
// Drop "llvm." and take the first dotted component. That will be the target
@@ -915,7 +915,7 @@ Intrinsic::ID Function::lookupIntrinsicID(StringRef Name) {
void Function::updateAfterNameChange() {
LibFuncCache = UnknownLibFunc;
StringRef Name = getName();
- if (!Name.startswith("llvm.")) {
+ if (!Name.starts_with("llvm.")) {
HasLLVMReservedName = false;
IntID = Intrinsic::not_intrinsic;
return;
diff --git a/llvm/lib/IR/Mangler.cpp b/llvm/lib/IR/Mangler.cpp
index 8d9880ecba58e..3acac2c3e3db1 100644
--- a/llvm/lib/IR/Mangler.cpp
+++ b/llvm/lib/IR/Mangler.cpp
@@ -149,8 +149,8 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
// Don't add byte count suffixes when '\01' or '?' are in the first
// character.
- if (Name.startswith("\01") ||
- (DL.doNotMangleLeadingQuestionMark() && Name.startswith("?")))
+ if (Name.starts_with("\01") ||
+ (DL.doNotMangleLeadingQuestionMark() && Name.starts_with("?")))
MSFunc = nullptr;
CallingConv::ID CC =
diff --git a/llvm/lib/IR/PassInstrumentation.cpp b/llvm/lib/IR/PassInstrumentation.cpp
index d85cefbbe6f7b..6d5f3acb7a4d3 100644
--- a/llvm/lib/IR/PassInstrumentation.cpp
+++ b/llvm/lib/IR/PassInstrumentation.cpp
@@ -35,7 +35,8 @@ bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) {
StringRef Prefix = PassID;
if (Pos != StringRef::npos)
Prefix = PassID.substr(0, Pos);
- return any_of(Specials, [Prefix](StringRef S) { return Prefix.endswith(S); });
+ return any_of(Specials,
+ [Prefix](StringRef S) { return Prefix.ends_with(S); });
}
} // namespace llvm
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index a185ca3fb8dc1..85d779c98a9b1 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -834,7 +834,7 @@ struct TargetTypeInfo {
static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {
LLVMContext &C = Ty->getContext();
StringRef Name = Ty->getName();
- if (Name.startswith("spirv."))
+ if (Name.starts_with("spirv."))
return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit,
TargetExtType::CanBeGlobal);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index f137f0468c3c5..60122ccfc78c2 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -958,7 +958,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) {
void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
// There used to be various other llvm.dbg.* nodes, but we don't support
// upgrading them and we want to reserve the namespace for future uses.
- if (NMD.getName().startswith("llvm.dbg."))
+ if (NMD.getName().starts_with("llvm.dbg."))
CheckDI(NMD.getName() == "llvm.dbg.cu",
"unrecognized named metadata node in the llvm.dbg namespace", &NMD);
for (const MDNode *MD : NMD.operands()) {
diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp
index aa5817dceed54..da46592bd3819 100644
--- a/llvm/lib/InterfaceStub/IFSHandler.cpp
+++ b/llvm/lib/InterfaceStub/IFSHandler.cpp
@@ -167,7 +167,7 @@ template <> struct MappingTraits<IFSStubTriple> {
bool usesTriple(StringRef Buf) {
for (line_iterator I(MemoryBufferRef(Buf, "ELFStub")); !I.is_at_eof(); ++I) {
StringRef Line = (*I).trim();
- if (Line.startswith("Target:")) {
+ if (Line.starts_with("Target:")) {
if (Line == "Target:" || Line.contains("{")) {
return false;
}
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index 868169e782250..f839fe944e18f 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -91,7 +91,7 @@ bool LTOModule::isBitcodeForTarget(MemoryBuffer *Buffer,
expectedToErrorOrAndEmitErrors(Context, getBitcodeTargetTriple(*BCOrErr));
if (!TripleOrErr)
return false;
- return StringRef(*TripleOrErr).startswith(TriplePrefix);
+ return StringRef(*TripleOrErr).starts_with(TriplePrefix);
}
std::string LTOModule::getProducerString(MemoryBuffer *Buffer) {
@@ -382,17 +382,17 @@ void LTOModule::addDefinedDataSymbol(StringRef Name, const GlobalValue *v) {
// special case if this data blob is an ObjC class definition
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(v)) {
StringRef Section = GV->getSection();
- if (Section.startswith("__OBJC,__class,")) {
+ if (Section.starts_with("__OBJC,__class,")) {
addObjCClass(GV);
}
// special case if this data blob is an ObjC category definition
- else if (Section.startswith("__OBJC,__category,")) {
+ else if (Section.starts_with("__OBJC,__category,")) {
addObjCCategory(GV);
}
// special case if this data blob is the list of referenced classes
- else if (Section.startswith("__OBJC,__cls_refs,")) {
+ else if (Section.starts_with("__OBJC,__cls_refs,")) {
addObjCClassRef(GV);
}
}
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 5d8fae28bf404..1bd562d1e8ae2 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1569,7 +1569,7 @@ Error IRLinker::run() {
std::string ModuleId = SrcM->getModuleIdentifier();
StringRef FileName = llvm::sys::path::filename(ModuleId);
bool SrcIsLibDevice =
- FileName.startswith("libdevice") && FileName.endswith(".10.bc");
+ FileName.starts_with("libdevice") && FileName.ends_with(".10.bc");
bool SrcHasLibDeviceDL =
(SrcM->getDataLayoutStr().empty() ||
SrcM->getDataLayoutStr() == "e-i64:64-v16:16-v32:32-n16:32:64");
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index e4d18d8a7dd5b..cb8af1aa99551 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -72,7 +72,7 @@ class ELFObjectWriter;
struct ELFWriter;
bool isDwoSection(const MCSectionELF &Sec) {
- return Sec.getName().endswith(".dwo");
+ return Sec.getName().ends_with(".dwo");
}
class SymbolTableWriter {
@@ -872,7 +872,7 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
const DebugCompressionType CompressionType = MAI->compressDebugSections();
if (CompressionType == DebugCompressionType::None ||
- !SectionName.startswith(".debug_")) {
+ !SectionName.starts_with(".debug_")) {
Asm.writeSectionData(W.OS, &Section, Layout);
return;
}
@@ -1250,7 +1250,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
StringRef Prefix = AliasName.substr(0, Pos);
StringRef Rest = AliasName.substr(Pos);
StringRef Tail = Rest;
- if (Rest.startswith("@@@"))
+ if (Rest.starts_with("@@@"))
Tail = Rest.substr(Symbol.isUndefined() ? 2 : 1);
auto *Alias =
@@ -1268,8 +1268,8 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
if (!Symbol.isUndefined() && S.KeepOriginalSym)
continue;
- if (Symbol.isUndefined() && Rest.startswith("@@") &&
- !Rest.startswith("@@@")) {
+ if (Symbol.isUndefined() && Rest.starts_with("@@") &&
+ !Rest.starts_with("@@@")) {
Asm.getContext().reportError(S.Loc, "default version symbol " +
AliasName + " must be defined");
continue;
@@ -1287,7 +1287,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
for (const MCSymbol *&Sym : AddrsigSyms) {
if (const MCSymbol *R = Renames.lookup(cast<MCSymbolELF>(Sym)))
Sym = R;
- if (Sym->isInSection() && Sym->getName().startswith(".L"))
+ if (Sym->isInSection() && Sym->getName().starts_with(".L"))
Sym = Sym->getSection().getBeginSymbol();
Sym->setUsedInReloc();
}
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 5a157fc36d8e2..9e1d108ac14dc 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -467,12 +467,12 @@ void MCAsmStreamer::addExplicitComment(const Twine &T) {
StringRef c = T.getSingleStringRef();
if (c.equals(StringRef(MAI->getSeparatorString())))
return;
- if (c.startswith(StringRef("//"))) {
+ if (c.starts_with(StringRef("//"))) {
ExplicitCommentToEmit.append("\t");
ExplicitCommentToEmit.append(MAI->getCommentString());
// drop //
ExplicitCommentToEmit.append(c.slice(2, c.size()).str());
- } else if (c.startswith(StringRef("/*"))) {
+ } else if (c.starts_with(StringRef("/*"))) {
size_t p = 2, len = c.size() - 2;
// emit each line in comment as separate newline.
do {
@@ -485,7 +485,7 @@ void MCAsmStreamer::addExplicitComment(const Twine &T) {
ExplicitCommentToEmit.append("\n");
p = newp + 1;
} while (p < len);
- } else if (c.startswith(StringRef(MAI->getCommentString()))) {
+ } else if (c.starts_with(StringRef(MAI->getCommentString()))) {
ExplicitCommentToEmit.append("\t");
ExplicitCommentToEmit.append(c.str());
} else if (c.front() == '#') {
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index ba4e1c3c4107e..6e72b5062a1d8 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -271,7 +271,7 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
// label, if used.
bool IsTemporary = CanBeUnnamed;
if (AllowTemporaryLabels && !IsTemporary)
- IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
+ IsTemporary = Name.starts_with(MAI->getPrivateGlobalPrefix());
SmallString<128> NewName = Name;
bool AddSuffix = AlwaysAddSuffix;
@@ -382,8 +382,8 @@ MCContext::createXCOFFSymbolImpl(const StringMapEntry<bool> *Name,
return new (nullptr, *this) MCSymbolXCOFF(nullptr, IsTemporary);
StringRef OriginalName = Name->first();
- if (OriginalName.startswith("._Renamed..") ||
- OriginalName.startswith("_Renamed.."))
+ if (OriginalName.starts_with("._Renamed..") ||
+ OriginalName.starts_with("_Renamed.."))
reportError(SMLoc(), "invalid symbol name from source");
if (MAI->isValidUnquotedName(OriginalName))
@@ -628,8 +628,8 @@ void MCContext::recordELFMergeableSectionInfo(StringRef SectionName,
}
bool MCContext::isELFImplicitMergeableSectionNamePrefix(StringRef SectionName) {
- return SectionName.startswith(".rodata.str") ||
- SectionName.startswith(".rodata.cst");
+ return SectionName.starts_with(".rodata.str") ||
+ SectionName.starts_with(".rodata.cst");
}
bool MCContext::isELFGenericMergeableSection(StringRef SectionName) {
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index f94fc48a033d4..d0face9140de6 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1211,7 +1211,7 @@ void MCGenDwarfLabelEntry::Make(MCSymbol *Symbol, MCStreamer *MCOS,
// The dwarf label's name does not have the symbol name's leading
// underbar if any.
StringRef Name = Symbol->getName();
- if (Name.startswith("_"))
+ if (Name.starts_with("_"))
Name = Name.substr(1, Name.size()-1);
// Get the dwarf file number to be used for the dwarf label.
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index f13549b24e2dd..e08404ae0ad92 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -32,7 +32,7 @@
using namespace llvm;
AsmLexer::AsmLexer(const MCAsmInfo &MAI) : MAI(MAI) {
- AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
+ AllowAtInIdentifier = !StringRef(MAI.getCommentString()).starts_with("@");
LexMotorolaIntegers = MAI.shouldUseMotorolaIntegers();
}
@@ -605,7 +605,7 @@ AsmToken AsmLexer::LexSingleQuote() {
StringRef Res = StringRef(TokStart,CurPtr - TokStart);
long long Value;
- if (Res.startswith("\'\\")) {
+ if (Res.starts_with("\'\\")) {
char theChar = Res[2];
switch (theChar) {
default: Value = theChar; break;
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 825b12e037d30..8e508dbdb1c69 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -1991,7 +1991,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
// Otherwise, we have a normal instruction or directive.
// Directives start with "."
- if (IDVal.startswith(".") && IDVal != ".") {
+ if (IDVal.starts_with(".") && IDVal != ".") {
// There are several entities interested in parsing directives:
//
// 1. The target-specific assembly parser. Some directives are target
diff --git a/llvm/lib/MC/MCParser/COFFMasmParser.cpp b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
index 34aa5bf2ae39c..8adb0dcddb16a 100644
--- a/llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
@@ -250,7 +250,7 @@ bool COFFMasmParser::ParseDirectiveSegment(StringRef Directive, SMLoc Loc) {
SmallVector<char, 247> SectionNameVector;
StringRef Class;
- if (SegmentName == "_TEXT" || SegmentName.startswith("_TEXT$")) {
+ if (SegmentName == "_TEXT" || SegmentName.starts_with("_TEXT$")) {
if (SegmentName.size() == 5) {
SectionName = ".text";
} else {
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index dbfe0d83e1b29..93e1d2f44b8c5 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -531,7 +531,7 @@ static bool allowSectionTypeMismatch(const Triple &TT, StringRef SectionName,
// MIPS .debug_* sections should have SHT_MIPS_DWARF section type to
// distinguish among sections contain DWARF and ECOFF debug formats,
// but in assembly files these sections have SHT_PROGBITS type.
- return SectionName.startswith(".debug_") && Type == ELF::SHT_PROGBITS;
+ return SectionName.starts_with(".debug_") && Type == ELF::SHT_PROGBITS;
}
return false;
}
@@ -634,7 +634,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
unsigned Type = ELF::SHT_PROGBITS;
if (TypeName.empty()) {
- if (SectionName.startswith(".note"))
+ if (SectionName.starts_with(".note"))
Type = ELF::SHT_NOTE;
else if (hasPrefix(SectionName, ".init_array"))
Type = ELF::SHT_INIT_ARRAY;
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 8960e739365c6..51563ea86a6c5 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -2117,7 +2117,7 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
// Treat ".<number>" as a valid identifier in this context.
IDVal = getTok().getString();
Lex(); // always eat a token
- if (!IDVal.startswith("."))
+ if (!IDVal.starts_with("."))
return Error(IDLoc, "unexpected token at start of statement");
} else if (parseIdentifier(IDVal, StartOfStatement)) {
if (!TheCondState.Ignore) {
@@ -7190,7 +7190,7 @@ bool MasmParser::parseDirectiveRadix(SMLoc DirectiveLoc) {
bool MasmParser::parseDirectiveEcho(SMLoc DirectiveLoc) {
std::string Message = parseStringTo(AsmToken::EndOfStatement);
llvm::outs() << Message;
- if (!StringRef(Message).endswith("\n"))
+ if (!StringRef(Message).ends_with("\n"))
llvm::outs() << '\n';
return false;
}
diff --git a/llvm/lib/MC/StringTableBuilder.cpp b/llvm/lib/MC/StringTableBuilder.cpp
index 0e4f72e136151..df316bae98cea 100644
--- a/llvm/lib/MC/StringTableBuilder.cpp
+++ b/llvm/lib/MC/StringTableBuilder.cpp
@@ -150,7 +150,7 @@ void StringTableBuilder::finalizeStringTable(bool Optimize) {
StringRef Previous;
for (StringPair *P : Strings) {
StringRef S = P->first.val();
- if (Previous.endswith(S)) {
+ if (Previous.ends_with(S)) {
size_t Pos = Size - S.size() - (K != RAW);
if (isAligned(Alignment, Pos)) {
P->second = Pos;
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index b99df3837cc21..fd48d5080ff61 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -193,7 +193,7 @@ static void patchI64(raw_pwrite_stream &Stream, uint64_t Value,
}
bool isDwoSection(const MCSection &Sec) {
- return Sec.getName().endswith(".dwo");
+ return Sec.getName().ends_with(".dwo");
}
class WasmObjectWriter : public MCObjectWriter {
@@ -529,7 +529,7 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
const auto *SymA = cast<MCSymbolWasm>(&RefA->getSymbol());
// The .init_array isn't translated as data, so don't do relocations in it.
- if (FixupSection.getName().startswith(".init_array")) {
+ if (FixupSection.getName().starts_with(".init_array")) {
SymA->setUsedInInitArray();
return;
}
@@ -1491,7 +1491,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
<< Section.getGroup() << "\n";);
// .init_array sections are handled specially elsewhere.
- if (SectionName.startswith(".init_array"))
+ if (SectionName.starts_with(".init_array"))
continue;
// Code is handled separately
@@ -1526,7 +1526,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
StringRef Name = SectionName;
// For user-defined custom sections, strip the prefix
- if (Name.startswith(".custom_section."))
+ if (Name.starts_with(".custom_section."))
Name = Name.substr(strlen(".custom_section."));
MCSymbol *Begin = Sec.getBeginSymbol();
@@ -1851,9 +1851,9 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
// Translate .init_array section contents into start functions.
for (const MCSection &S : Asm) {
const auto &WS = static_cast<const MCSectionWasm &>(S);
- if (WS.getName().startswith(".fini_array"))
+ if (WS.getName().starts_with(".fini_array"))
report_fatal_error(".fini_array sections are unsupported");
- if (!WS.getName().startswith(".init_array"))
+ if (!WS.getName().starts_with(".init_array"))
continue;
if (WS.getFragmentList().empty())
continue;
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 1f73cb9884e0a..f265fafa59e74 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -241,7 +241,7 @@ class WinCOFFObjectWriter : public MCObjectWriter {
} // end anonymous namespace
static bool isDwoSection(const MCSection &Sec) {
- return Sec.getName().endswith(".dwo");
+ return Sec.getName().ends_with(".dwo");
}
//------------------------------------------------------------------------------
diff --git a/llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp b/llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp
index 622726be8ce5a..782d5b2f70c3e 100644
--- a/llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp
@@ -29,7 +29,7 @@ using namespace object;
using namespace COFF;
static bool isDebugSection(const Section &Sec) {
- return Sec.Name.startswith(".debug");
+ return Sec.Name.starts_with(".debug");
}
static uint64_t getNextRVA(const Object &Obj) {
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index 9d02ba051a0a8..ceb676dec22f5 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -52,11 +52,11 @@ using namespace llvm::object;
using SectionPred = std::function<bool(const SectionBase &Sec)>;
static bool isDebugSection(const SectionBase &Sec) {
- return StringRef(Sec.Name).startswith(".debug") || Sec.Name == ".gdb_index";
+ return StringRef(Sec.Name).starts_with(".debug") || Sec.Name == ".gdb_index";
}
static bool isDWOSection(const SectionBase &Sec) {
- return StringRef(Sec.Name).endswith(".dwo");
+ return StringRef(Sec.Name).ends_with(".dwo");
}
static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) {
@@ -214,7 +214,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
static bool isCompressable(const SectionBase &Sec) {
return !(Sec.Flags & ELF::SHF_COMPRESSED) &&
- StringRef(Sec.Name).startswith(".debug");
+ StringRef(Sec.Name).starts_with(".debug");
}
static Error replaceDebugSections(
@@ -248,7 +248,7 @@ static bool isAArch64MappingSymbol(const Symbol &Sym) {
StringRef Name = Sym.Name;
if (!Name.consume_front("$x") && !Name.consume_front("$d"))
return false;
- return Name.empty() || Name.startswith(".");
+ return Name.empty() || Name.starts_with(".");
}
static bool isArmMappingSymbol(const Symbol &Sym) {
@@ -259,7 +259,7 @@ static bool isArmMappingSymbol(const Symbol &Sym) {
if (!Name.consume_front("$a") && !Name.consume_front("$d") &&
!Name.consume_front("$t"))
return false;
- return Name.empty() || Name.startswith(".");
+ return Name.empty() || Name.starts_with(".");
}
// Check if the symbol should be preserved because it is required by ABI.
@@ -361,7 +361,7 @@ static Error updateAndRemoveSymbols(const CommonConfig &Config,
if ((Config.DiscardMode == DiscardType::All ||
(Config.DiscardMode == DiscardType::Locals &&
- StringRef(Sym.Name).startswith(".L"))) &&
+ StringRef(Sym.Name).starts_with(".L"))) &&
Sym.Binding == STB_LOCAL && Sym.getShndx() != SHN_UNDEF &&
Sym.Type != STT_FILE && Sym.Type != STT_SECTION)
return true;
@@ -448,7 +448,7 @@ static Error replaceAndRemoveSections(const CommonConfig &Config,
return true;
if (&Sec == Obj.SectionNames)
return false;
- if (StringRef(Sec.Name).startswith(".gnu.warning"))
+ if (StringRef(Sec.Name).starts_with(".gnu.warning"))
return false;
// We keep the .ARM.attribute section to maintain compatibility
// with Debian derived distributions. This is a bug in their
@@ -662,7 +662,7 @@ static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
auto AddSection = [&](StringRef Name, ArrayRef<uint8_t> Data) {
OwnedDataSection &NewSection =
Obj.addSection<OwnedDataSection>(Name, Data);
- if (Name.startswith(".note") && Name != ".note.GNU-stack")
+ if (Name.starts_with(".note") && Name != ".note.GNU-stack")
NewSection.Type = SHT_NOTE;
return Error::success();
};
diff --git a/llvm/lib/ObjCopy/MachO/MachOObject.h b/llvm/lib/ObjCopy/MachO/MachOObject.h
index 1cbd2eb5f320c..b3303fd291c82 100644
--- a/llvm/lib/ObjCopy/MachO/MachOObject.h
+++ b/llvm/lib/ObjCopy/MachO/MachOObject.h
@@ -119,8 +119,8 @@ struct SymbolEntry {
}
bool isSwiftSymbol() const {
- return StringRef(Name).startswith("_$s") ||
- StringRef(Name).startswith("_$S");
+ return StringRef(Name).starts_with("_$s") ||
+ StringRef(Name).starts_with("_$S");
}
std::optional<uint32_t> section() const {
diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
index e5af59f93280a..5bba1dea9adf0 100644
--- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
+++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
@@ -22,11 +22,11 @@ using namespace object;
using SectionPred = std::function<bool(const Section &Sec)>;
static bool isDebugSection(const Section &Sec) {
- return Sec.Name.startswith(".debug");
+ return Sec.Name.starts_with(".debug");
}
static bool isLinkerSection(const Section &Sec) {
- return Sec.Name.startswith("reloc.") || Sec.Name == "linking";
+ return Sec.Name.starts_with("reloc.") || Sec.Name == "linking";
}
static bool isNameSection(const Section &Sec) { return Sec.Name == "name"; }
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index fdd87824e2293..4ac4d727afb69 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -227,7 +227,7 @@ Expected<StringRef> BigArchiveMemberHeader::getRawName() const {
StringRef NameTerminator = "`\n";
StringRef NameStringWithNameTerminator =
StringRef(ArMemHdr->Name, NameLenWithPadding + NameTerminator.size());
- if (!NameStringWithNameTerminator.endswith(NameTerminator)) {
+ if (!NameStringWithNameTerminator.ends_with(NameTerminator)) {
uint64_t Offset =
reinterpret_cast<const char *>(ArMemHdr->Name + NameLenWithPadding) -
Parent->getData().data();
@@ -315,7 +315,7 @@ Expected<StringRef> ArchiveMemberHeader::getName(uint64_t Size) const {
return Parent->getStringTable().begin() + StringOffset;
}
- if (Name.startswith("#1/")) {
+ if (Name.starts_with("#1/")) {
uint64_t NameLength;
if (Name.substr(3).rtrim(' ').getAsInteger(10, NameLength)) {
std::string Buf;
@@ -524,7 +524,7 @@ Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
// The actual start of the file is after the name and any necessary
// even-alignment padding.
StartOfFile += ((Name.size() + 1) >> 1) << 1;
- } else if (Name.startswith("#1/")) {
+ } else if (Name.starts_with("#1/")) {
uint64_t NameSize;
StringRef RawNameSize = Name.substr(3).rtrim(' ');
if (RawNameSize.getAsInteger(10, NameSize)) {
@@ -671,7 +671,7 @@ Expected<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) {
std::unique_ptr<Archive> Ret;
StringRef Buffer = Source.getBuffer();
- if (Buffer.startswith(BigArchiveMagic))
+ if (Buffer.starts_with(BigArchiveMagic))
Ret = std::make_unique<BigArchive>(Source, Err);
else
Ret = std::make_unique<Archive>(Source, Err);
@@ -711,11 +711,11 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
ErrorAsOutParameter ErrAsOutParam(&Err);
StringRef Buffer = Data.getBuffer();
// Check for sufficient magic.
- if (Buffer.startswith(ThinArchiveMagic)) {
+ if (Buffer.starts_with(ThinArchiveMagic)) {
IsThin = true;
- } else if (Buffer.startswith(ArchiveMagic)) {
+ } else if (Buffer.starts_with(ArchiveMagic)) {
IsThin = false;
- } else if (Buffer.startswith(BigArchiveMagic)) {
+ } else if (Buffer.starts_with(BigArchiveMagic)) {
Format = K_AIXBIG;
IsThin = false;
return;
@@ -800,7 +800,7 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
return;
}
- if (Name.startswith("#1/")) {
+ if (Name.starts_with("#1/")) {
Format = K_BSD;
// We know this is BSD, so getName will work since there is no string table.
Expected<StringRef> NameOrErr = C->getName();
diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index 2cca1f728cc71..eeb13ffe9c11b 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -91,11 +91,11 @@ static ImportNameType getNameType(StringRef Sym, StringRef ExtName,
// stdcall function still omits the underscore (IMPORT_NAME_NOPREFIX).
// See the comment in isDecorated in COFFModuleDefinition.cpp for more
// details.
- if (ExtName.startswith("_") && ExtName.contains('@') && !MinGW)
+ if (ExtName.starts_with("_") && ExtName.contains('@') && !MinGW)
return IMPORT_NAME;
if (Sym != ExtName)
return IMPORT_NAME_UNDECORATE;
- if (Machine == IMAGE_FILE_MACHINE_I386 && Sym.startswith("_"))
+ if (Machine == IMAGE_FILE_MACHINE_I386 && Sym.starts_with("_"))
return IMPORT_NAME_NOPREFIX;
return IMPORT_NAME;
}
@@ -105,7 +105,7 @@ static Expected<std::string> replace(StringRef S, StringRef From,
size_t Pos = S.find(From);
// From and To may be mangled, but substrings in S may not.
- if (Pos == StringRef::npos && From.startswith("_") && To.startswith("_")) {
+ if (Pos == StringRef::npos && From.starts_with("_") && To.starts_with("_")) {
From = From.substr(1);
To = To.substr(1);
Pos = S.find(From);
diff --git a/llvm/lib/Object/COFFModuleDefinition.cpp b/llvm/lib/Object/COFFModuleDefinition.cpp
index a33949733c8e4..648f01f823d00 100644
--- a/llvm/lib/Object/COFFModuleDefinition.cpp
+++ b/llvm/lib/Object/COFFModuleDefinition.cpp
@@ -74,7 +74,7 @@ static bool isDecorated(StringRef Sym, bool MingwDef) {
// We can't check for a leading underscore here, since function names
// themselves can start with an underscore, while a second one still needs
// to be added.
- return Sym.startswith("@") || Sym.contains("@@") || Sym.startswith("?") ||
+ return Sym.starts_with("@") || Sym.contains("@@") || Sym.starts_with("?") ||
(!MingwDef && Sym.contains('@'));
}
@@ -97,7 +97,7 @@ class Lexer {
}
case '=':
Buf = Buf.drop_front();
- if (Buf.startswith("=")) {
+ if (Buf.starts_with("=")) {
Buf = Buf.drop_front();
return Token(EqualEqual, "==");
}
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 574f7a7cf1f45..8700912614db8 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -336,7 +336,7 @@ bool COFFObjectFile::isDebugSection(DataRefImpl Ref) const {
return false;
}
StringRef SectionName = SectionNameOrErr.get();
- return SectionName.startswith(".debug");
+ return SectionName.starts_with(".debug");
}
unsigned COFFObjectFile::getSectionID(SectionRef Sec) const {
@@ -1203,9 +1203,9 @@ COFFObjectFile::getSectionName(const coff_section *Sec) const {
StringRef Name = StringRef(Sec->Name, COFF::NameSize).split('\0').first;
// Check for string table entry. First byte is '/'.
- if (Name.startswith("/")) {
+ if (Name.starts_with("/")) {
uint32_t Offset;
- if (Name.startswith("//")) {
+ if (Name.starts_with("//")) {
if (decodeBase64StringEntry(Name.substr(2), Offset))
return createStringError(object_error::parse_failed,
"invalid section name");
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 5e6c6ea794275..1cfd0a069463e 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -2066,9 +2066,9 @@ bool MachOObjectFile::isDebugSection(DataRefImpl Sec) const {
return false;
}
StringRef SectionName = SectionNameOrErr.get();
- return SectionName.startswith("__debug") ||
- SectionName.startswith("__zdebug") ||
- SectionName.startswith("__apple") || SectionName == "__gdb_index" ||
+ return SectionName.starts_with("__debug") ||
+ SectionName.starts_with("__zdebug") ||
+ SectionName.starts_with("__apple") || SectionName == "__gdb_index" ||
SectionName == "__swift_ast";
}
@@ -2083,7 +2083,7 @@ ArrayRef<uint8_t> getSegmentContents(const MachOObjectFile &Obj,
return {};
}
auto &Segment = SegmentOrErr.get();
- if (StringRef(Segment.segname, 16).startswith(SegmentName))
+ if (StringRef(Segment.segname, 16).starts_with(SegmentName))
return arrayRefFromStringRef(Obj.getData().slice(
Segment.fileoff, Segment.fileoff + Segment.filesize));
return {};
@@ -2469,7 +2469,7 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name,
if (c == Name.npos || c == 0)
goto guess_library;
V = Name.slice(c+1, Name.npos);
- if (!V.startswith("Versions/"))
+ if (!V.starts_with("Versions/"))
goto guess_library;
d = Name.rfind('/', c);
if (d == Name.npos)
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp
index dc73937863e6d..ab073e18cb466 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -215,7 +215,7 @@ uint32_t ModuleSymbolTable::getSymbolFlags(Symbol S) const {
GV->hasExternalWeakLinkage())
Res |= BasicSymbolRef::SF_Weak;
- if (GV->getName().startswith("llvm."))
+ if (GV->getName().starts_with("llvm."))
Res |= BasicSymbolRef::SF_FormatSpecific;
else if (auto *Var = dyn_cast<GlobalVariable>(GV)) {
if (Var->getSection() == "llvm.metadata")
diff --git a/llvm/lib/Object/RecordStreamer.cpp b/llvm/lib/Object/RecordStreamer.cpp
index d01076c0bceb1..891016cf74755 100644
--- a/llvm/lib/Object/RecordStreamer.cpp
+++ b/llvm/lib/Object/RecordStreamer.cpp
@@ -206,7 +206,7 @@ void RecordStreamer::flushSymverDirectives() {
for (auto AliasName : Symver.second) {
std::pair<StringRef, StringRef> Split = AliasName.split("@@@");
SmallString<128> NewName;
- if (!Split.second.empty() && !Split.second.startswith("@")) {
+ if (!Split.second.empty() && !Split.second.starts_with("@")) {
// Special processing for "@@@" according
// https://sourceware.org/binutils/docs/as/Symver.html
const char *Separator = IsDefined ? "@@" : "@";
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 0982c7e2efbb9..168fb57935d6d 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -1092,7 +1092,7 @@ Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) {
} else if (Sec.Name == "target_features") {
if (Error Err = parseTargetFeaturesSection(Ctx))
return Err;
- } else if (Sec.Name.startswith("reloc.")) {
+ } else if (Sec.Name.starts_with("reloc.")) {
if (Error Err = parseRelocSection(Sec.Name, Ctx))
return Err;
}
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 40f81f867efa4..d54faec208667 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -666,7 +666,7 @@ bool ELFState<ELFT>::initImplicitHeader(ContiguousBlobAccumulator &CBA,
initSymtabSectionHeader(Header, SymtabType::Static, CBA, YAMLSec);
else if (SecName == ".dynsym")
initSymtabSectionHeader(Header, SymtabType::Dynamic, CBA, YAMLSec);
- else if (SecName.startswith(".debug_")) {
+ else if (SecName.starts_with(".debug_")) {
// If a ".debug_*" section's type is a preserved one, e.g., SHT_DYNAMIC, we
// will not treat it as a debug section.
if (YAMLSec && !isa<ELFYAML::RawContentSection>(YAMLSec))
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index c47d4eaa309dc..9d845a0c7c487 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1291,10 +1291,10 @@ StringRef ScalarTraits<ELFYAML::YAMLIntUInt>::input(StringRef Scalar, void *Ctx,
StringRef ErrMsg = "invalid number";
// We do not accept negative hex numbers because their meaning is ambiguous.
// For example, would -0xfffffffff mean 1 or INT32_MIN?
- if (Scalar.empty() || Scalar.startswith("-0x"))
+ if (Scalar.empty() || Scalar.starts_with("-0x"))
return ErrMsg;
- if (Scalar.startswith("-")) {
+ if (Scalar.starts_with("-")) {
const int64_t MinVal = Is64 ? INT64_MIN : INT32_MIN;
long long Int;
if (getAsSignedInteger(Scalar, /*Radix=*/0, Int) || (Int < MinVal))
@@ -1559,7 +1559,7 @@ void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
// When the Type string does not have a "SHT_" prefix, we know it is not a
// description of a regular ELF output section.
TypeStr = getStringValue(IO, "Type");
- if (TypeStr.startswith("SHT_") || isInteger(TypeStr))
+ if (TypeStr.starts_with("SHT_") || isInteger(TypeStr))
IO.mapRequired("Type", Type);
}
diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp
index 8f764ec779f3f..9fcc91a9278db 100644
--- a/llvm/lib/Option/ArgList.cpp
+++ b/llvm/lib/Option/ArgList.cpp
@@ -186,7 +186,7 @@ const char *ArgList::GetOrMakeJoinedArgString(unsigned Index,
StringRef RHS) const {
StringRef Cur = getArgString(Index);
if (Cur.size() == LHS.size() + RHS.size() &&
- Cur.startswith(LHS) && Cur.endswith(RHS))
+ Cur.starts_with(LHS) && Cur.ends_with(RHS))
return Cur.data();
return MakeArgString(LHS + RHS);
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 50eebf1f954bb..a4d0f4a549372 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -152,7 +152,7 @@ static bool isInput(const ArrayRef<StringLiteral> &Prefixes, StringRef Arg) {
if (Arg == "-")
return true;
for (const StringRef &Prefix : Prefixes)
- if (Arg.startswith(Prefix))
+ if (Arg.starts_with(Prefix))
return false;
return true;
}
@@ -161,10 +161,10 @@ static bool isInput(const ArrayRef<StringLiteral> &Prefixes, StringRef Arg) {
static unsigned matchOption(const OptTable::Info *I, StringRef Str,
bool IgnoreCase) {
for (auto Prefix : I->Prefixes) {
- if (Str.startswith(Prefix)) {
+ if (Str.starts_with(Prefix)) {
StringRef Rest = Str.substr(Prefix.size());
bool Matched = IgnoreCase ? Rest.starts_with_insensitive(I->getName())
- : Rest.startswith(I->getName());
+ : Rest.starts_with(I->getName());
if (Matched)
return Prefix.size() + StringRef(I->getName()).size();
}
@@ -175,7 +175,7 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str,
// Returns true if one of the Prefixes + In.Names matches Option
static bool optionMatches(const OptTable::Info &In, StringRef Option) {
for (auto Prefix : In.Prefixes)
- if (Option.endswith(In.getName()))
+ if (Option.ends_with(In.getName()))
if (Option.slice(0, Option.size() - In.getName().size()) == Prefix)
return true;
return false;
@@ -197,7 +197,7 @@ OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
std::vector<std::string> Result;
for (StringRef Val : Candidates)
- if (Val.startswith(Arg) && Arg.compare(Val))
+ if (Val.starts_with(Arg) && Arg.compare(Val))
Result.push_back(std::string(Val));
return Result;
}
@@ -221,7 +221,7 @@ OptTable::findByPrefix(StringRef Cur, Visibility VisibilityMask,
std::string S = (Prefix + In.getName() + "\t").str();
if (In.HelpText)
S += In.HelpText;
- if (StringRef(S).startswith(Cur) && S != std::string(Cur) + "\t")
+ if (StringRef(S).starts_with(Cur) && S != std::string(Cur) + "\t")
Ret.push_back(S);
}
}
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index a5f9b5424358e..5ed159e24e355 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -562,7 +562,7 @@ static bool checkParametrizedPassName(StringRef Name, StringRef PassName) {
// normal pass name w/o parameters == default parameters
if (Name.empty())
return true;
- return Name.startswith("<") && Name.endswith(">");
+ return Name.starts_with("<") && Name.ends_with(">");
}
static std::optional<OptimizationLevel> parseOptLevel(StringRef S) {
@@ -1130,8 +1130,8 @@ Expected<bool> parseWinEHPrepareOptions(StringRef Params) {
/// Tests whether a pass name starts with a valid prefix for a default pipeline
/// alias.
static bool startsWithDefaultPipelineAliasPrefix(StringRef Name) {
- return Name.startswith("default") || Name.startswith("thinlto") ||
- Name.startswith("lto");
+ return Name.starts_with("default") || Name.starts_with("thinlto") ||
+ Name.starts_with("lto");
}
/// Tests whether registered callbacks will accept a given pass name.
diff --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index 5fce3dd5f7b70..f7bf42e5c4d25 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -337,7 +337,7 @@ StringRef GCOVFunction::getName(bool demangle) const {
return Name;
if (demangled.empty()) {
do {
- if (Name.startswith("_Z")) {
+ if (Name.starts_with("_Z")) {
// Name is guaranteed to be NUL-terminated.
if (char *res = itaniumDemangle(Name.data())) {
demangled = res;
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 236b083a1e215..a53e44d85d090 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -385,7 +385,7 @@ StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) {
if (FileName.empty())
return PGOFuncName;
// Drop the file name including ':'. See also getPGOFuncName.
- if (PGOFuncName.startswith(FileName))
+ if (PGOFuncName.starts_with(FileName))
PGOFuncName = PGOFuncName.drop_front(FileName.size() + 1);
return PGOFuncName;
}
diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
index 24d828f69c712..8529a17987352 100644
--- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp
+++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
@@ -277,7 +277,7 @@ bool DwarfInstrProfCorrelator<IntPtrT>::isDIEOfProbe(const DWARFDie &Die) {
if (!Die.hasChildren())
return false;
if (const char *Name = Die.getName(DINameKind::ShortName))
- return StringRef(Name).startswith(getInstrProfCountersVarPrefix());
+ return StringRef(Name).starts_with(getInstrProfCountersVarPrefix());
return false;
}
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 74f3f3270c4c7..f3fd456ae7973 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -246,7 +246,7 @@ bool TextInstrProfReader::hasFormat(const MemoryBuffer &Buffer) {
Error TextInstrProfReader::readHeader() {
Symtab.reset(new InstrProfSymtab());
- while (Line->startswith(":")) {
+ while (Line->starts_with(":")) {
StringRef Str = Line->substr(1);
if (Str.equals_insensitive("ir"))
ProfileKind |= InstrProfKind::IRInstrumentation;
@@ -386,7 +386,7 @@ TextInstrProfReader::readValueProfileData(InstrProfRecord &Record) {
Error TextInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) {
// Skip empty lines and comments.
- while (!Line.is_at_end() && (Line->empty() || Line->startswith("#")))
+ while (!Line.is_at_end() && (Line->empty() || Line->starts_with("#")))
++Line;
// If we hit EOF while looking for a name, we're done.
if (Line.is_at_end()) {
@@ -428,7 +428,7 @@ Error TextInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) {
}
// Bitmap byte information is indicated with special character.
- if (Line->startswith("$")) {
+ if (Line->starts_with("$")) {
Record.BitmapBytes.clear();
// Read the number of bitmap bytes.
uint64_t NumBitmapBytes;
@@ -1017,7 +1017,7 @@ class llvm::InstrProfReaderItaniumRemapper
std::pair<StringRef, StringRef> Parts = {StringRef(), Name};
while (true) {
Parts = Parts.second.split(':');
- if (Parts.first.startswith("_Z"))
+ if (Parts.first.starts_with("_Z"))
return Parts.first;
if (Parts.second.empty())
return Name;
diff --git a/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp b/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
index 593677214e582..6271b16226934 100644
--- a/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
+++ b/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
@@ -225,7 +225,7 @@ ItaniumManglingCanonicalizer::addEquivalence(FragmentKind Kind, StringRef First,
// arguments. This mostly just falls out, as almost all template names
// are valid as <name>s, but we also want to parse <substitution>s as
// <name>s, even though they're not.
- else if (Str.startswith("S"))
+ else if (Str.starts_with("S"))
// Parse the substitution and optional following template arguments.
N = P->Demangler.parseType();
else
@@ -289,8 +289,8 @@ parseMaybeMangledName(CanonicalizingDemangler &Demangler, StringRef Mangling,
// encoding 6memcpy 7memmove
// consistent with how they are encoded as local-names inside a C++ mangling.
Node *N;
- if (Mangling.startswith("_Z") || Mangling.startswith("__Z") ||
- Mangling.startswith("___Z") || Mangling.startswith("____Z"))
+ if (Mangling.starts_with("_Z") || Mangling.starts_with("__Z") ||
+ Mangling.starts_with("___Z") || Mangling.starts_with("____Z"))
N = Demangler.parse();
else
N = Demangler.make<itanium_demangle::NameType>(
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index ed92713c2c627..98d0aa794529c 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -180,12 +180,12 @@ static bool isOffsetLegal(unsigned L) { return (L & 0xffff) == L; }
/// Stores the FunctionHash (a.k.a. CFG Checksum) into \p FunctionHash.
static bool parseMetadata(const StringRef &Input, uint64_t &FunctionHash,
uint32_t &Attributes) {
- if (Input.startswith("!CFGChecksum:")) {
+ if (Input.starts_with("!CFGChecksum:")) {
StringRef CFGInfo = Input.substr(strlen("!CFGChecksum:")).trim();
return !CFGInfo.getAsInteger(10, FunctionHash);
}
- if (Input.startswith("!Attributes:")) {
+ if (Input.starts_with("!Attributes:")) {
StringRef Attrib = Input.substr(strlen("!Attributes:")).trim();
return !Attrib.getAsInteger(10, Attributes);
}
diff --git a/llvm/lib/ProfileData/SymbolRemappingReader.cpp b/llvm/lib/ProfileData/SymbolRemappingReader.cpp
index 78457beb3e495..805f66b68ce7b 100644
--- a/llvm/lib/ProfileData/SymbolRemappingReader.cpp
+++ b/llvm/lib/ProfileData/SymbolRemappingReader.cpp
@@ -37,7 +37,7 @@ Error SymbolRemappingReader::read(MemoryBuffer &B) {
StringRef Line = *LineIt;
Line = Line.ltrim(' ');
// line_iterator only detects comments starting in column 1.
- if (Line.startswith("#") || Line.empty())
+ if (Line.starts_with("#") || Line.empty())
continue;
SmallVector<StringRef, 4> Parts;
diff --git a/llvm/lib/Remarks/YAMLRemarkParser.cpp b/llvm/lib/Remarks/YAMLRemarkParser.cpp
index 947adbba10a21..218b6691398bb 100644
--- a/llvm/lib/Remarks/YAMLRemarkParser.cpp
+++ b/llvm/lib/Remarks/YAMLRemarkParser.cpp
@@ -136,7 +136,7 @@ Expected<std::unique_ptr<YAMLRemarkParser>> remarks::createYAMLParserFromMeta(
StrTab = std::move(*MaybeStrTab);
}
// If it starts with "---", there is no external file.
- if (!Buf.startswith("---")) {
+ if (!Buf.starts_with("---")) {
// At this point, we expect Buf to contain the external file path.
StringRef ExternalFilePath = Buf;
SmallString<80> FullPath;
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 3b668ba82ebbc..9f89d63bb0fda 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -652,7 +652,7 @@ std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
static void expandTildeExpr(SmallVectorImpl<char> &Path) {
StringRef PathStr(Path.begin(), Path.size());
- if (PathStr.empty() || !PathStr.startswith("~"))
+ if (PathStr.empty() || !PathStr.starts_with("~"))
return;
PathStr = PathStr.drop_front();
diff --git a/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp b/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
index 88e44eb0bfbb9..8ce6f94e7341d 100644
--- a/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
@@ -37,7 +37,7 @@ static bool shouldTagGlobal(GlobalVariable &G) {
// For now, don't instrument constant data, as it'll be in .rodata anyway. It
// may be worth instrumenting these in future to stop them from being used as
// gadgets.
- if (G.getName().startswith("llvm.") || G.isThreadLocal() || G.isConstant()) {
+ if (G.getName().starts_with("llvm.") || G.isThreadLocal() || G.isConstant()) {
Meta.Memtag = false;
G.setSanitizerMetadata(Meta);
return false;
diff --git a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
index 3687492c3e3e4..76dd5a2d713eb 100644
--- a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
@@ -212,7 +212,7 @@ bool SLSBLRThunkInserter::insertThunks(MachineModuleInfo &MMI,
void SLSBLRThunkInserter::populateThunk(MachineFunction &MF) {
// FIXME: How to better communicate Register number, rather than through
// name and lookup table?
- assert(MF.getName().startswith(getThunkPrefix()));
+ assert(MF.getName().starts_with(getThunkPrefix()));
auto ThunkIt = llvm::find_if(
SLSBLRThunks, [&MF](auto T) { return T.Name == MF.getName(); });
assert(ThunkIt != std::end(SLSBLRThunks));
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index fbe1bf3c5238d..238269cf27bd7 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -3250,7 +3250,7 @@ ParseStatus AArch64AsmParser::tryParseFPImm(OperandVector &Operands) {
}
// Parse hexadecimal representation.
- if (Tok.is(AsmToken::Integer) && Tok.getString().startswith("0x")) {
+ if (Tok.is(AsmToken::Integer) && Tok.getString().starts_with("0x")) {
if (Tok.getIntVal() > 255 || isNegative)
return TokError("encoded floating point value out of range");
@@ -7524,7 +7524,7 @@ bool AArch64AsmParser::parseAuthExpr(const MCExpr *&Res, SMLoc &EndLoc) {
AsmToken Tok = Parser.getTok();
// Look for '_sym at AUTH' ...
- if (Tok.is(AsmToken::Identifier) && Tok.getIdentifier().endswith("@AUTH")) {
+ if (Tok.is(AsmToken::Identifier) && Tok.getIdentifier().ends_with("@AUTH")) {
StringRef SymName = Tok.getIdentifier().drop_back(strlen("@AUTH"));
if (SymName.contains('@'))
return TokError(
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
index c798ab5f03b3c..3437b6dc8ae0c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
@@ -478,7 +478,7 @@ static bool eatTerm(StringRef& mangledName, const char c) {
template <size_t N>
static bool eatTerm(StringRef& mangledName, const char (&str)[N]) {
- if (mangledName.startswith(StringRef(str, N-1))) {
+ if (mangledName.starts_with(StringRef(str, N - 1))) {
drop_front(mangledName, N-1);
return true;
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 0c38fa32c6f33..97db19064f6fd 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -601,8 +601,8 @@ StringRef AMDGPUTargetMachine::getFeatureString(const Function &F) const {
/// Predicate for Internalize pass.
static bool mustPreserveGV(const GlobalValue &GV) {
if (const Function *F = dyn_cast<Function>(&GV))
- return F->isDeclaration() || F->getName().startswith("__asan_") ||
- F->getName().startswith("__sanitizer_") ||
+ return F->isDeclaration() || F->getName().starts_with("__asan_") ||
+ F->getName().starts_with("__sanitizer_") ||
AMDGPU::isEntryFunctionCC(F->getCallingConv());
GV.removeDeadConstantUsers();
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
index f854c8c16e5aa..584e41bfd5461 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
@@ -30,7 +30,7 @@ MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
// Set metadata access for the explicit section
StringRef SectionName = GO->getSection();
- if (SectionName.startswith(".AMDGPU.comment."))
+ if (SectionName.starts_with(".AMDGPU.comment."))
SK = SectionKind::getMetadata();
return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index cb877a4695f1e..3316659671bd1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -892,7 +892,7 @@ bool GCNTTIImpl::isReadRegisterSourceOfDivergence(
return true;
// Special case scalar registers that start with 'v'.
- if (RegName.startswith("vcc") || RegName.empty())
+ if (RegName.starts_with("vcc") || RegName.empty())
return false;
// VGPR or AGPR is divergent. There aren't any specially named vector
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 092845d391a3b..ed93948868da1 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -2570,7 +2570,7 @@ static bool isRegularReg(RegisterKind Kind) {
static const RegInfo* getRegularRegInfo(StringRef Str) {
for (const RegInfo &Reg : RegularRegisters)
- if (Str.startswith(Reg.Name))
+ if (Str.starts_with(Reg.Name))
return &Reg;
return nullptr;
}
@@ -4479,7 +4479,7 @@ bool AMDGPUAsmParser::validateBLGP(const MCInst &Inst,
SMLoc BLGPLoc = getBLGPLoc(Operands);
if (!BLGPLoc.isValid())
return true;
- bool IsNeg = StringRef(BLGPLoc.getPointer()).startswith("neg:");
+ bool IsNeg = StringRef(BLGPLoc.getPointer()).starts_with("neg:");
auto FB = getFeatureBits();
bool UsesNeg = false;
if (FB[AMDGPU::FeatureGFX940Insts]) {
@@ -5974,20 +5974,20 @@ StringRef AMDGPUAsmParser::parseMnemonicSuffix(StringRef Name) {
setForcedDPP(false);
setForcedSDWA(false);
- if (Name.endswith("_e64_dpp")) {
+ if (Name.ends_with("_e64_dpp")) {
setForcedDPP(true);
setForcedEncodingSize(64);
return Name.substr(0, Name.size() - 8);
- } else if (Name.endswith("_e64")) {
+ } else if (Name.ends_with("_e64")) {
setForcedEncodingSize(64);
return Name.substr(0, Name.size() - 4);
- } else if (Name.endswith("_e32")) {
+ } else if (Name.ends_with("_e32")) {
setForcedEncodingSize(32);
return Name.substr(0, Name.size() - 4);
- } else if (Name.endswith("_dpp")) {
+ } else if (Name.ends_with("_dpp")) {
setForcedDPP(true);
return Name.substr(0, Name.size() - 4);
- } else if (Name.endswith("_sdwa")) {
+ } else if (Name.ends_with("_sdwa")) {
setForcedSDWA(true);
return Name.substr(0, Name.size() - 5);
}
@@ -6010,7 +6010,7 @@ bool AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
Operands.push_back(AMDGPUOperand::CreateToken(this, Name, NameLoc));
- bool IsMIMG = Name.startswith("image_");
+ bool IsMIMG = Name.starts_with("image_");
while (!trySkipToken(AsmToken::EndOfStatement)) {
OperandMode Mode = OperandMode_Default;
@@ -6150,7 +6150,7 @@ unsigned AMDGPUAsmParser::getCPolKind(StringRef Id, StringRef Mnemo,
bool &Disabling) const {
Disabling = Id.consume_front("no");
- if (isGFX940() && !Mnemo.startswith("s_")) {
+ if (isGFX940() && !Mnemo.starts_with("s_")) {
return StringSwitch<unsigned>(Id)
.Case("nt", AMDGPU::CPol::NT)
.Case("sc0", AMDGPU::CPol::SC0)
@@ -6282,13 +6282,13 @@ ParseStatus AMDGPUAsmParser::parseTH(OperandVector &Operands, int64_t &TH) {
else if (Value == "TH_STORE_LU" || Value == "TH_LOAD_RT_WB" ||
Value == "TH_LOAD_NT_WB") {
return Error(StringLoc, "invalid th value");
- } else if (Value.startswith("TH_ATOMIC_")) {
+ } else if (Value.starts_with("TH_ATOMIC_")) {
Value = Value.drop_front(10);
TH = AMDGPU::CPol::TH_TYPE_ATOMIC;
- } else if (Value.startswith("TH_LOAD_")) {
+ } else if (Value.starts_with("TH_LOAD_")) {
Value = Value.drop_front(8);
TH = AMDGPU::CPol::TH_TYPE_LOAD;
- } else if (Value.startswith("TH_STORE_")) {
+ } else if (Value.starts_with("TH_STORE_")) {
Value = Value.drop_front(9);
TH = AMDGPU::CPol::TH_TYPE_STORE;
} else {
@@ -6733,7 +6733,7 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
AMDGPU::IsaVersion ISA = AMDGPU::getIsaVersion(getSTI().getCPU());
bool Failed = true;
- bool Sat = CntName.endswith("_sat");
+ bool Sat = CntName.ends_with("_sat");
if (CntName == "vmcnt" || CntName == "vmcnt_sat") {
Failed = encodeCnt(ISA, IntVal, CntVal, Sat, encodeVmcnt, decodeVmcnt);
@@ -7206,7 +7206,7 @@ ParseStatus AMDGPUAsmParser::parseInterpAttr(OperandVector &Operands) {
if (!parseId(Str))
return ParseStatus::NoMatch;
- if (!Str.startswith("attr"))
+ if (!Str.starts_with("attr"))
return Error(S, "invalid interpolation attribute");
StringRef Chan = Str.take_back(2);
@@ -7297,7 +7297,7 @@ bool
AMDGPUAsmParser::trySkipId(const StringRef Pref, const StringRef Id) {
if (isToken(AsmToken::Identifier)) {
StringRef Tok = getTokenStr();
- if (Tok.startswith(Pref) && Tok.drop_front(Pref.size()) == Id) {
+ if (Tok.starts_with(Pref) && Tok.drop_front(Pref.size()) == Id) {
lex();
return true;
}
@@ -8446,7 +8446,7 @@ bool AMDGPUAsmParser::parseDimId(unsigned &Encoding) {
Token += Suffix;
StringRef DimId = Token;
- if (DimId.startswith("SQ_RSRC_IMG_"))
+ if (DimId.starts_with("SQ_RSRC_IMG_"))
DimId = DimId.drop_front(12);
const AMDGPU::MIMGDimInfo *DimInfo = AMDGPU::getMIMGDimInfoByAsmSuffix(DimId);
diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
index 1f11beb71101b..f0ba870b6619b 100644
--- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
+++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
@@ -2184,7 +2184,7 @@ AMDGPUDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
// Code Object V3 kernel descriptors.
StringRef Name = Symbol.Name;
- if (Symbol.Type == ELF::STT_OBJECT && Name.endswith(StringRef(".kd"))) {
+ if (Symbol.Type == ELF::STT_OBJECT && Name.ends_with(StringRef(".kd"))) {
Size = 64; // Size = 64 regardless of success or failure.
return decodeKernelDescriptor(Name.drop_back(3), Bytes, Address);
}
diff --git a/llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp b/llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp
index 2a15c0123b740..195dc4f9a0f41 100644
--- a/llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp
+++ b/llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp
@@ -163,11 +163,11 @@ class R600OpenCLImageTypeLoweringPass : public ModulePass {
Value *Replacement = nullptr;
StringRef Name = F->getName();
- if (Name.startswith(GetImageResourceIDFunc)) {
+ if (Name.starts_with(GetImageResourceIDFunc)) {
Replacement = ConstantInt::get(Int32Type, ResourceID);
- } else if (Name.startswith(GetImageSizeFunc)) {
+ } else if (Name.starts_with(GetImageSizeFunc)) {
Replacement = &ImageSizeArg;
- } else if (Name.startswith(GetImageFormatFunc)) {
+ } else if (Name.starts_with(GetImageFormatFunc)) {
Replacement = &ImageFormatArg;
} else {
continue;
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index a7f4d63229b7e..aedb832b94594 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -14461,7 +14461,7 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
return std::pair(0U, RC);
}
- if (Constraint.startswith("{") && Constraint.endswith("}")) {
+ if (Constraint.starts_with("{") && Constraint.ends_with("}")) {
StringRef RegName(Constraint.data() + 1, Constraint.size() - 2);
if (RegName.consume_front("v")) {
RC = &AMDGPU::VGPR_32RegClass;
diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
index f8eb67199f623..e0c23e40e19d8 100644
--- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
@@ -728,7 +728,7 @@ bool SIMachineFunctionInfo::mayUseAGPRs(const Function &F) const {
for (const auto &CI : IA->ParseConstraints()) {
for (StringRef Code : CI.Codes) {
Code.consume_front("{");
- if (Code.startswith("a"))
+ if (Code.starts_with("a"))
return true;
}
}
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index 68d561a0d9f78..8faa9e5f6d30b 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -716,9 +716,9 @@ void AMDGPUTargetID::setTargetIDFromFeaturesString(StringRef FS) {
static TargetIDSetting
getTargetIDSettingFromFeatureString(StringRef FeatureString) {
- if (FeatureString.endswith("-"))
+ if (FeatureString.ends_with("-"))
return TargetIDSetting::Off;
- if (FeatureString.endswith("+"))
+ if (FeatureString.ends_with("+"))
return TargetIDSetting::On;
llvm_unreachable("Malformed feature string");
@@ -729,9 +729,9 @@ void AMDGPUTargetID::setTargetIDFromTargetIDStream(StringRef TargetID) {
TargetID.split(TargetIDSplit, ':');
for (const auto &FeatureString : TargetIDSplit) {
- if (FeatureString.startswith("xnack"))
+ if (FeatureString.starts_with("xnack"))
XnackSetting = getTargetIDSettingFromFeatureString(FeatureString);
- if (FeatureString.startswith("sramecc"))
+ if (FeatureString.starts_with("sramecc"))
SramEccSetting = getTargetIDSettingFromFeatureString(FeatureString);
}
}
@@ -1578,7 +1578,7 @@ unsigned getTgtId(const StringRef Name) {
if (Val.MaxIndex == 0 && Name == Val.Name)
return Val.Tgt;
- if (Val.MaxIndex > 0 && Name.startswith(Val.Name)) {
+ if (Val.MaxIndex > 0 && Name.starts_with(Val.Name)) {
StringRef Suffix = Name.drop_front(Val.Name.size());
unsigned Id;
diff --git a/llvm/lib/Target/ARM/ARMSLSHardening.cpp b/llvm/lib/Target/ARM/ARMSLSHardening.cpp
index 09357ae2e3a38..23d72b34902d0 100644
--- a/llvm/lib/Target/ARM/ARMSLSHardening.cpp
+++ b/llvm/lib/Target/ARM/ARMSLSHardening.cpp
@@ -210,7 +210,7 @@ ArmInsertedThunks SLSBLRThunkInserter::insertThunks(MachineModuleInfo &MMI,
void SLSBLRThunkInserter::populateThunk(MachineFunction &MF) {
// FIXME: How to better communicate Register number, rather than through
// name and lookup table?
- assert(MF.getName().startswith(getThunkPrefix()));
+ assert(MF.getName().starts_with(getThunkPrefix()));
auto ThunkIt = llvm::find_if(
SLSBLRThunks, [&MF](auto T) { return T.Name == MF.getName(); });
assert(ThunkIt != std::end(SLSBLRThunks));
diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
index a80d485e750be..deae3c9df35d0 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
@@ -130,9 +130,9 @@ computeTargetABI(const Triple &TT, StringRef CPU,
if (ABIName == "aapcs16")
return ARMBaseTargetMachine::ARM_ABI_AAPCS16;
- else if (ABIName.startswith("aapcs"))
+ else if (ABIName.starts_with("aapcs"))
return ARMBaseTargetMachine::ARM_ABI_AAPCS;
- else if (ABIName.startswith("apcs"))
+ else if (ABIName.starts_with("apcs"))
return ARMBaseTargetMachine::ARM_ABI_APCS;
llvm_unreachable("Unhandled/unknown ABI Name!");
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index ab0a8f78b1563..cbc5e52108651 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -1984,7 +1984,7 @@ bool ARMTTIImpl::isLoweredToCall(const Function *F) {
return BaseT::isLoweredToCall(F);
// Assume all Arm-specific intrinsics map to an instruction.
- if (F->getName().startswith("llvm.arm"))
+ if (F->getName().starts_with("llvm.arm"))
return false;
switch (F->getIntrinsicID()) {
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 20b52ebc544a1..7405e370e0487 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -191,7 +191,7 @@ class ARMMnemonicSets {
/// Returns true iff a given mnemonic is a CDE instruction
bool isCDEInstr(StringRef Mnemonic) {
// Quick check before searching the set
- if (!Mnemonic.startswith("cx") && !Mnemonic.startswith("vcx"))
+ if (!Mnemonic.starts_with("cx") && !Mnemonic.starts_with("vcx"))
return false;
return CDE.count(Mnemonic);
}
@@ -199,7 +199,7 @@ class ARMMnemonicSets {
/// Returns true iff a given mnemonic is a VPT-predicable CDE instruction
/// (possibly with a predication suffix "e" or "t")
bool isVPTPredicableCDEInstr(StringRef Mnemonic) {
- if (!Mnemonic.startswith("vcx"))
+ if (!Mnemonic.starts_with("vcx"))
return false;
return CDEWithVPTSuffix.count(Mnemonic);
}
@@ -207,17 +207,17 @@ class ARMMnemonicSets {
/// Returns true iff a given mnemonic is an IT-predicable CDE instruction
/// (possibly with a condition suffix)
bool isITPredicableCDEInstr(StringRef Mnemonic) {
- if (!Mnemonic.startswith("cx"))
+ if (!Mnemonic.starts_with("cx"))
return false;
- return Mnemonic.startswith("cx1a") || Mnemonic.startswith("cx1da") ||
- Mnemonic.startswith("cx2a") || Mnemonic.startswith("cx2da") ||
- Mnemonic.startswith("cx3a") || Mnemonic.startswith("cx3da");
+ return Mnemonic.starts_with("cx1a") || Mnemonic.starts_with("cx1da") ||
+ Mnemonic.starts_with("cx2a") || Mnemonic.starts_with("cx2da") ||
+ Mnemonic.starts_with("cx3a") || Mnemonic.starts_with("cx3da");
}
/// Return true iff a given mnemonic is an integer CDE instruction with
/// dual-register destination
bool isCDEDualRegInstr(StringRef Mnemonic) {
- if (!Mnemonic.startswith("cx"))
+ if (!Mnemonic.starts_with("cx"))
return false;
return Mnemonic == "cx1d" || Mnemonic == "cx1da" ||
Mnemonic == "cx2d" || Mnemonic == "cx2da" ||
@@ -6083,7 +6083,7 @@ bool ARMAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) {
case AsmToken::LBrac:
return parseMemory(Operands);
case AsmToken::LCurly:
- return parseRegisterList(Operands, !Mnemonic.startswith("clr"));
+ return parseRegisterList(Operands, !Mnemonic.starts_with("clr"));
case AsmToken::Dollar:
case AsmToken::Hash: {
// #42 -> immediate
@@ -6308,7 +6308,7 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
Mnemonic == "vcvta" || Mnemonic == "vcvtn" || Mnemonic == "vcvtp" ||
Mnemonic == "vcvtm" || Mnemonic == "vrinta" || Mnemonic == "vrintn" ||
Mnemonic == "vrintp" || Mnemonic == "vrintm" || Mnemonic == "hvc" ||
- Mnemonic.startswith("vsel") || Mnemonic == "vins" || Mnemonic == "vmovx" ||
+ Mnemonic.starts_with("vsel") || Mnemonic == "vins" || Mnemonic == "vmovx" ||
Mnemonic == "bxns" || Mnemonic == "blxns" ||
Mnemonic == "vdot" || Mnemonic == "vmmla" ||
Mnemonic == "vudot" || Mnemonic == "vsdot" ||
@@ -6339,7 +6339,7 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
Mnemonic == "vrintne" ||
Mnemonic == "vcmult" || Mnemonic == "vcmule" ||
Mnemonic == "vpsele" || Mnemonic == "vpselt" ||
- Mnemonic.startswith("vq")))) {
+ Mnemonic.starts_with("vq")))) {
unsigned CC = ARMCondCodeFromString(Mnemonic.substr(Mnemonic.size()-2));
if (CC != ~0U) {
Mnemonic = Mnemonic.slice(0, Mnemonic.size() - 2);
@@ -6349,7 +6349,7 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
// Next, determine if we have a carry setting bit. We explicitly ignore all
// the instructions we know end in 's'.
- if (Mnemonic.endswith("s") &&
+ if (Mnemonic.ends_with("s") &&
!(Mnemonic == "cps" || Mnemonic == "mls" ||
Mnemonic == "mrs" || Mnemonic == "smmls" || Mnemonic == "vabs" ||
Mnemonic == "vcls" || Mnemonic == "vmls" || Mnemonic == "vmrs" ||
@@ -6368,7 +6368,7 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
// The "cps" instruction can have a interrupt mode operand which is glued into
// the mnemonic. Check if this is the case, split it and parse the imod op
- if (Mnemonic.startswith("cps")) {
+ if (Mnemonic.starts_with("cps")) {
// Split out any imod code.
unsigned IMod =
StringSwitch<unsigned>(Mnemonic.substr(Mnemonic.size()-2, 2))
@@ -6397,16 +6397,16 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
}
// The "it" instruction has the condition mask on the end of the mnemonic.
- if (Mnemonic.startswith("it")) {
+ if (Mnemonic.starts_with("it")) {
ITMask = Mnemonic.slice(2, Mnemonic.size());
Mnemonic = Mnemonic.slice(0, 2);
}
- if (Mnemonic.startswith("vpst")) {
+ if (Mnemonic.starts_with("vpst")) {
ITMask = Mnemonic.slice(4, Mnemonic.size());
Mnemonic = Mnemonic.slice(0, 4);
}
- else if (Mnemonic.startswith("vpt")) {
+ else if (Mnemonic.starts_with("vpt")) {
ITMask = Mnemonic.slice(3, Mnemonic.size());
Mnemonic = Mnemonic.slice(0, 3);
}
@@ -6441,14 +6441,14 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic,
if (Mnemonic == "bkpt" || Mnemonic == "cbnz" || Mnemonic == "setend" ||
Mnemonic == "cps" || Mnemonic == "it" || Mnemonic == "cbz" ||
Mnemonic == "trap" || Mnemonic == "hlt" || Mnemonic == "udf" ||
- Mnemonic.startswith("crc32") || Mnemonic.startswith("cps") ||
- Mnemonic.startswith("vsel") || Mnemonic == "vmaxnm" ||
+ Mnemonic.starts_with("crc32") || Mnemonic.starts_with("cps") ||
+ Mnemonic.starts_with("vsel") || Mnemonic == "vmaxnm" ||
Mnemonic == "vminnm" || Mnemonic == "vcvta" || Mnemonic == "vcvtn" ||
Mnemonic == "vcvtp" || Mnemonic == "vcvtm" || Mnemonic == "vrinta" ||
Mnemonic == "vrintn" || Mnemonic == "vrintp" || Mnemonic == "vrintm" ||
- Mnemonic.startswith("aes") || Mnemonic == "hvc" || Mnemonic == "setpan" ||
- Mnemonic.startswith("sha1") || Mnemonic.startswith("sha256") ||
- (FullInst.startswith("vmull") && FullInst.endswith(".p64")) ||
+ Mnemonic.starts_with("aes") || Mnemonic == "hvc" || Mnemonic == "setpan" ||
+ Mnemonic.starts_with("sha1") || Mnemonic.starts_with("sha256") ||
+ (FullInst.starts_with("vmull") && FullInst.ends_with(".p64")) ||
Mnemonic == "vmovx" || Mnemonic == "vins" ||
Mnemonic == "vudot" || Mnemonic == "vsdot" ||
Mnemonic == "vcmla" || Mnemonic == "vcadd" ||
@@ -6466,14 +6466,14 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic,
Mnemonic == "cset" || Mnemonic == "csetm" ||
(hasCDE() && MS.isCDEInstr(Mnemonic) &&
!MS.isITPredicableCDEInstr(Mnemonic)) ||
- Mnemonic.startswith("vpt") || Mnemonic.startswith("vpst") ||
+ Mnemonic.starts_with("vpt") || Mnemonic.starts_with("vpst") ||
Mnemonic == "pac" || Mnemonic == "pacbti" || Mnemonic == "aut" ||
Mnemonic == "bti" ||
(hasMVE() &&
- (Mnemonic.startswith("vst2") || Mnemonic.startswith("vld2") ||
- Mnemonic.startswith("vst4") || Mnemonic.startswith("vld4") ||
- Mnemonic.startswith("wlstp") || Mnemonic.startswith("dlstp") ||
- Mnemonic.startswith("letp")))) {
+ (Mnemonic.starts_with("vst2") || Mnemonic.starts_with("vld2") ||
+ Mnemonic.starts_with("vst4") || Mnemonic.starts_with("vld4") ||
+ Mnemonic.starts_with("wlstp") || Mnemonic.starts_with("dlstp") ||
+ Mnemonic.starts_with("letp")))) {
// These mnemonics are never predicable
CanAcceptPredicationCode = false;
} else if (!isThumb()) {
@@ -6486,7 +6486,7 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic,
Mnemonic != "pldw" && Mnemonic != "ldc2" && Mnemonic != "ldc2l" &&
Mnemonic != "stc2" && Mnemonic != "stc2l" &&
Mnemonic != "tsb" &&
- !Mnemonic.startswith("rfe") && !Mnemonic.startswith("srs");
+ !Mnemonic.starts_with("rfe") && !Mnemonic.starts_with("srs");
} else if (isThumbOne()) {
if (hasV6MOps())
CanAcceptPredicationCode = Mnemonic != "movs";
@@ -6782,16 +6782,16 @@ bool ARMAsmParser::shouldOmitVectorPredicateOperand(StringRef Mnemonic,
if (!hasMVE() || Operands.size() < 3)
return true;
- if (Mnemonic.startswith("vld2") || Mnemonic.startswith("vld4") ||
- Mnemonic.startswith("vst2") || Mnemonic.startswith("vst4"))
+ if (Mnemonic.starts_with("vld2") || Mnemonic.starts_with("vld4") ||
+ Mnemonic.starts_with("vst2") || Mnemonic.starts_with("vst4"))
return true;
- if (Mnemonic.startswith("vctp") || Mnemonic.startswith("vpnot"))
+ if (Mnemonic.starts_with("vctp") || Mnemonic.starts_with("vpnot"))
return false;
- if (Mnemonic.startswith("vmov") &&
- !(Mnemonic.startswith("vmovl") || Mnemonic.startswith("vmovn") ||
- Mnemonic.startswith("vmovx"))) {
+ if (Mnemonic.starts_with("vmov") &&
+ !(Mnemonic.starts_with("vmovl") || Mnemonic.starts_with("vmovn") ||
+ Mnemonic.starts_with("vmovx"))) {
for (auto &Operand : Operands) {
if (static_cast<ARMOperand &>(*Operand).isVectorIndex() ||
((*Operand).isReg() &&
@@ -6831,7 +6831,7 @@ static bool isDataTypeToken(StringRef Tok) {
// in the .td files that matches the suffix instead of having it be
// a literal string token the way it is now.
static bool doesIgnoreDataTypeSuffix(StringRef Mnemonic, StringRef DT) {
- return Mnemonic.startswith("vldm") || Mnemonic.startswith("vstm");
+ return Mnemonic.starts_with("vldm") || Mnemonic.starts_with("vstm");
}
static void applyMnemonicAliases(StringRef &Mnemonic,
@@ -7001,8 +7001,8 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// ITxyz -> xyz1 (e.g. ITEET -> 1101)
// Note: See the ARM::PredBlockMask enum in
// /lib/Target/ARM/Utils/ARMBaseInfo.h
- if (Mnemonic == "it" || Mnemonic.startswith("vpt") ||
- Mnemonic.startswith("vpst")) {
+ if (Mnemonic == "it" || Mnemonic.starts_with("vpt") ||
+ Mnemonic.starts_with("vpst")) {
SMLoc Loc = Mnemonic == "it" ? SMLoc::getFromPointer(NameLoc.getPointer() + 2) :
Mnemonic == "vpt" ? SMLoc::getFromPointer(NameLoc.getPointer() + 3) :
SMLoc::getFromPointer(NameLoc.getPointer() + 4);
@@ -7080,8 +7080,8 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// scalar predication operand we do not add the vector one and leave until
// now to fix it up.
if (CanAcceptVPTPredicationCode && Mnemonic != "vmov" &&
- !Mnemonic.startswith("vcmp") &&
- !(Mnemonic.startswith("vcvt") && Mnemonic != "vcvta" &&
+ !Mnemonic.starts_with("vcmp") &&
+ !(Mnemonic.starts_with("vcvt") && Mnemonic != "vcvta" &&
Mnemonic != "vcvtn" && Mnemonic != "vcvtp" && Mnemonic != "vcvtm")) {
SMLoc Loc = SMLoc::getFromPointer(NameLoc.getPointer() + Mnemonic.size() +
CarrySetting);
@@ -7226,10 +7226,10 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// special parsing. So now we have to see if they require vector
// predication and replace the scalar one with the vector predication
// operand if that is the case.
- else if (Mnemonic == "vmov" || Mnemonic.startswith("vcmp") ||
- (Mnemonic.startswith("vcvt") && !Mnemonic.startswith("vcvta") &&
- !Mnemonic.startswith("vcvtn") && !Mnemonic.startswith("vcvtp") &&
- !Mnemonic.startswith("vcvtm"))) {
+ else if (Mnemonic == "vmov" || Mnemonic.starts_with("vcmp") ||
+ (Mnemonic.starts_with("vcvt") && !Mnemonic.starts_with("vcvta") &&
+ !Mnemonic.starts_with("vcvtn") && !Mnemonic.starts_with("vcvtp") &&
+ !Mnemonic.starts_with("vcvtm"))) {
if (!shouldOmitVectorPredicateOperand(Mnemonic, Operands)) {
// We could not split the vector predicate off vcvt because it might
// have been the scalar vcvtt instruction. Now we know its a vector
@@ -7237,11 +7237,11 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// predicated vcvt with 'Then' predication or the vector vcvtt. We can
// distinguish the two based on the suffixes, if it is any of
// ".f16.f32", ".f32.f16", ".f16.f64" or ".f64.f16" then it is the vcvtt.
- if (Mnemonic.startswith("vcvtt") && Operands.size() >= 4) {
+ if (Mnemonic.starts_with("vcvtt") && Operands.size() >= 4) {
auto Sz1 = static_cast<ARMOperand &>(*Operands[2]);
auto Sz2 = static_cast<ARMOperand &>(*Operands[3]);
- if (!(Sz1.isToken() && Sz1.getToken().startswith(".f") &&
- Sz2.isToken() && Sz2.getToken().startswith(".f"))) {
+ if (!(Sz1.isToken() && Sz1.getToken().starts_with(".f") &&
+ Sz2.isToken() && Sz2.getToken().starts_with(".f"))) {
Operands.erase(Operands.begin());
SMLoc MLoc = SMLoc::getFromPointer(NameLoc.getPointer());
VPTPredicationCode = ARMVCC::Then;
@@ -12798,12 +12798,12 @@ bool ARMAsmParser::isMnemonicVPTPredicable(StringRef Mnemonic,
return false;
if (MS.isVPTPredicableCDEInstr(Mnemonic) ||
- (Mnemonic.startswith("vldrh") && Mnemonic != "vldrhi") ||
- (Mnemonic.startswith("vmov") &&
+ (Mnemonic.starts_with("vldrh") && Mnemonic != "vldrhi") ||
+ (Mnemonic.starts_with("vmov") &&
!(ExtraToken == ".f16" || ExtraToken == ".32" || ExtraToken == ".16" ||
ExtraToken == ".8")) ||
- (Mnemonic.startswith("vrint") && Mnemonic != "vrintr") ||
- (Mnemonic.startswith("vstrh") && Mnemonic != "vstrhi"))
+ (Mnemonic.starts_with("vrint") && Mnemonic != "vrintr") ||
+ (Mnemonic.starts_with("vstrh") && Mnemonic != "vstrhi"))
return true;
const char *predicable_prefixes[] = {
@@ -12833,5 +12833,5 @@ bool ARMAsmParser::isMnemonicVPTPredicable(StringRef Mnemonic,
return std::any_of(
std::begin(predicable_prefixes), std::end(predicable_prefixes),
- [&Mnemonic](const char *prefix) { return Mnemonic.startswith(prefix); });
+ [&Mnemonic](const char *prefix) { return Mnemonic.starts_with(prefix); });
}
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
index e84b597e4382e..1237e50c22fdc 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
@@ -177,7 +177,7 @@ void ARMTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI) {
switchVendor("aeabi");
const StringRef CPUString = STI.getCPU();
- if (!CPUString.empty() && !CPUString.startswith("generic")) {
+ if (!CPUString.empty() && !CPUString.starts_with("generic")) {
// FIXME: remove krait check when GNU tools support krait cpu
if (STI.hasFeature(ARM::ProcKrait)) {
emitTextAttribute(ARMBuildAttrs::CPU_name, "cortex-a9");
diff --git a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
index abe5dcc483409..1c8213b668f71 100644
--- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
+++ b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
@@ -251,13 +251,13 @@ bool AVRAsmPrinter::doFinalization(Module &M) {
}
auto *Section = cast<MCSectionELF>(TLOF.SectionForGlobal(&GO, TM));
- if (Section->getName().startswith(".data"))
+ if (Section->getName().starts_with(".data"))
NeedsCopyData = true;
- else if (Section->getName().startswith(".rodata") && SubTM->hasLPM())
+ else if (Section->getName().starts_with(".rodata") && SubTM->hasLPM())
// AVRs that have a separate program memory (that's most AVRs) store
// .rodata sections in RAM.
NeedsCopyData = true;
- else if (Section->getName().startswith(".bss"))
+ else if (Section->getName().starts_with(".bss"))
NeedsClearBSS = true;
}
diff --git a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
index 9634c16a30dc6..f2d1206d02316 100644
--- a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
+++ b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
@@ -338,7 +338,7 @@ bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
const auto *GV = dyn_cast<GlobalValue>(Call->getCalledOperand());
if (!GV)
return false;
- if (GV->getName().startswith("llvm.preserve.array.access.index")) {
+ if (GV->getName().starts_with("llvm.preserve.array.access.index")) {
CInfo.Kind = BPFPreserveArrayAI;
CInfo.Metadata = Call->getMetadata(LLVMContext::MD_preserve_access_index);
if (!CInfo.Metadata)
@@ -348,7 +348,7 @@ bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
CInfo.RecordAlignment = DL->getABITypeAlign(getBaseElementType(Call));
return true;
}
- if (GV->getName().startswith("llvm.preserve.union.access.index")) {
+ if (GV->getName().starts_with("llvm.preserve.union.access.index")) {
CInfo.Kind = BPFPreserveUnionAI;
CInfo.Metadata = Call->getMetadata(LLVMContext::MD_preserve_access_index);
if (!CInfo.Metadata)
@@ -358,7 +358,7 @@ bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
CInfo.Base = Call->getArgOperand(0);
return true;
}
- if (GV->getName().startswith("llvm.preserve.struct.access.index")) {
+ if (GV->getName().starts_with("llvm.preserve.struct.access.index")) {
CInfo.Kind = BPFPreserveStructAI;
CInfo.Metadata = Call->getMetadata(LLVMContext::MD_preserve_access_index);
if (!CInfo.Metadata)
@@ -369,7 +369,7 @@ bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
CInfo.RecordAlignment = DL->getABITypeAlign(getBaseElementType(Call));
return true;
}
- if (GV->getName().startswith("llvm.bpf.preserve.field.info")) {
+ if (GV->getName().starts_with("llvm.bpf.preserve.field.info")) {
CInfo.Kind = BPFPreserveFieldInfoAI;
CInfo.Metadata = nullptr;
// Check validity of info_kind as clang did not check this.
@@ -379,7 +379,7 @@ bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
CInfo.AccessIndex = InfoKind;
return true;
}
- if (GV->getName().startswith("llvm.bpf.preserve.type.info")) {
+ if (GV->getName().starts_with("llvm.bpf.preserve.type.info")) {
CInfo.Kind = BPFPreserveFieldInfoAI;
CInfo.Metadata = Call->getMetadata(LLVMContext::MD_preserve_access_index);
if (!CInfo.Metadata)
@@ -395,7 +395,7 @@ bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
CInfo.AccessIndex = BTF::TYPE_SIZE;
return true;
}
- if (GV->getName().startswith("llvm.bpf.preserve.enum.value")) {
+ if (GV->getName().starts_with("llvm.bpf.preserve.enum.value")) {
CInfo.Kind = BPFPreserveFieldInfoAI;
CInfo.Metadata = Call->getMetadata(LLVMContext::MD_preserve_access_index);
if (!CInfo.Metadata)
diff --git a/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp b/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
index 56c89f61b3195..81effc9b1db46 100644
--- a/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
+++ b/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
@@ -119,7 +119,7 @@ bool BPFCheckAndAdjustIR::removePassThroughBuiltin(Module &M) {
auto *GV = dyn_cast<GlobalValue>(Call->getCalledOperand());
if (!GV)
continue;
- if (!GV->getName().startswith("llvm.bpf.passthrough"))
+ if (!GV->getName().starts_with("llvm.bpf.passthrough"))
continue;
Changed = true;
Value *Arg = Call->getArgOperand(1);
@@ -149,7 +149,7 @@ bool BPFCheckAndAdjustIR::removeCompareBuiltin(Module &M) {
auto *GV = dyn_cast<GlobalValue>(Call->getCalledOperand());
if (!GV)
continue;
- if (!GV->getName().startswith("llvm.bpf.compare"))
+ if (!GV->getName().starts_with("llvm.bpf.compare"))
continue;
Changed = true;
diff --git a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
index fc4fb4d8f8001..dae1aeea35218 100644
--- a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
+++ b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
@@ -57,7 +57,7 @@ static bool BPFPreserveDITypeImpl(Function &F) {
if (!GV)
continue;
- if (GV->getName().startswith("llvm.bpf.btf.type.id")) {
+ if (GV->getName().starts_with("llvm.bpf.btf.type.id")) {
if (!Call->getMetadata(LLVMContext::MD_preserve_access_index))
report_fatal_error(
"Missing metadata for llvm.bpf.btf.type.id intrinsic");
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index f91ce7f250351..ebd8447eba850 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -977,7 +977,7 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
auto File = SP->getFile();
std::string FileName;
- if (!File->getFilename().startswith("/") && File->getDirectory().size())
+ if (!File->getFilename().starts_with("/") && File->getDirectory().size())
FileName = File->getDirectory().str() + "/" + File->getFilename().str();
else
FileName = std::string(File->getFilename());
@@ -1417,7 +1417,7 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
SecName = Sec->getName();
}
- if (ProcessingMapDef != SecName.startswith(".maps"))
+ if (ProcessingMapDef != SecName.starts_with(".maps"))
continue;
// Create a .rodata datasec if the global variable is an initialized
@@ -1443,7 +1443,7 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
DIGlobalVariable *DIGlobal = nullptr;
for (auto *GVE : GVs) {
DIGlobal = GVE->getVariable();
- if (SecName.startswith(".maps"))
+ if (SecName.starts_with(".maps"))
visitMapDefType(DIGlobal->getType(), GVTypeId);
else
visitTypeEntry(DIGlobal->getType(), GVTypeId, false, false);
diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
index e1ad15bbc7c17..4df811f188df6 100644
--- a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
@@ -116,13 +116,13 @@ HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
if (!llvm::count_if(Features.getFeatures(), IsQFloatFS)) {
auto getHvxVersion = [&Features](StringRef FS) -> StringRef {
for (StringRef F : llvm::reverse(Features.getFeatures())) {
- if (F.startswith("+hvxv"))
+ if (F.starts_with("+hvxv"))
return F;
}
for (StringRef F : llvm::reverse(Features.getFeatures())) {
if (F == "-hvx")
return StringRef();
- if (F.startswith("+hvx") || F == "-hvx")
+ if (F.starts_with("+hvx") || F == "-hvx")
return F.take_front(4); // Return "+hvx" or "-hvx".
}
return StringRef();
@@ -130,7 +130,7 @@ HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
bool AddQFloat = false;
StringRef HvxVer = getHvxVersion(FS);
- if (HvxVer.startswith("+hvxv")) {
+ if (HvxVer.starts_with("+hvxv")) {
int Ver = 0;
if (!HvxVer.drop_front(5).consumeInteger(10, Ver) && Ver >= 68)
AddQFloat = true;
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
index 8355de4cfe966..a7ac24e25a5fe 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
@@ -140,7 +140,7 @@ MCSection *HexagonTargetObjectFile::SelectSectionForGlobal(
// If the lookup table is used by more than one function, do not place
// it in text section.
- if (EmitLutInText && GO->getName().startswith("switch.table")) {
+ if (EmitLutInText && GO->getName().starts_with("switch.table")) {
if (const Function *Fn = getLutUsedFunction(GO))
return selectSectionForLookupTable(GO, TM, Fn);
}
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
index cf6fa78a20051..fffd5abd9f8bd 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
@@ -253,7 +253,7 @@ class HexagonTargetAsmStreamer : public HexagonTargetStreamer {
if (!Duplex.second.empty()) {
OS << Indent << Duplex.first << Separator;
InstTxt = Duplex.second;
- } else if (!HeadTail.first.trim().startswith("immext")) {
+ } else if (!HeadTail.first.trim().starts_with("immext")) {
InstTxt = Duplex.first;
}
if (!InstTxt.empty())
diff --git a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
index cf6f7800a4410..d0a89ad72b4c0 100644
--- a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
+++ b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
@@ -1048,15 +1048,15 @@ StringRef LanaiAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
StringRef Mnemonic = Name;
bool IsBRR = false;
- if (Name.endswith(".r")) {
+ if (Name.ends_with(".r")) {
Mnemonic = Name.substr(0, Name.size() - 2);
IsBRR = true;
}
// Match b?? and s?? (BR, BRR, and SCC instruction classes).
if (Mnemonic[0] == 'b' ||
- (Mnemonic[0] == 's' && !Mnemonic.startswith("sel") &&
- !Mnemonic.startswith("st"))) {
+ (Mnemonic[0] == 's' && !Mnemonic.starts_with("sel") &&
+ !Mnemonic.starts_with("st"))) {
// Parse instructions with a conditional code. For example, 'bne' is
// converted into two operands 'b' and 'ne'.
LPCC::CondCode CondCode =
@@ -1077,8 +1077,8 @@ StringRef LanaiAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
// We ignore .f here and assume they are flag-setting operations, not
// conditional codes (except for select instructions where flag-setting
// variants are not yet implemented).
- if (Mnemonic.startswith("sel") ||
- (!Mnemonic.endswith(".f") && !Mnemonic.startswith("st"))) {
+ if (Mnemonic.starts_with("sel") ||
+ (!Mnemonic.ends_with(".f") && !Mnemonic.starts_with("st"))) {
LPCC::CondCode CondCode = LPCC::suffixToLanaiCondCode(Mnemonic);
if (CondCode != LPCC::UNKNOWN) {
size_t Next = Mnemonic.rfind('.', Name.size());
@@ -1087,7 +1087,7 @@ StringRef LanaiAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
// expected by the generated matcher). If the mnemonic starts with 'sel'
// then include the period as part of the mnemonic, else don't include it
// as part of the mnemonic.
- if (Mnemonic.startswith("sel")) {
+ if (Mnemonic.starts_with("sel")) {
Mnemonic = Mnemonic.substr(0, Next + 1);
} else {
Mnemonic = Mnemonic.substr(0, Next);
@@ -1194,7 +1194,7 @@ bool LanaiAsmParser::ParseInstruction(ParseInstructionInfo & /*Info*/,
// If the instruction is a bt instruction with 1 operand (in assembly) then it
// is an unconditional branch instruction and the first two elements of
// operands need to be merged.
- if (Lexer.is(AsmToken::EndOfStatement) && Name.startswith("bt") &&
+ if (Lexer.is(AsmToken::EndOfStatement) && Name.starts_with("bt") &&
Operands.size() == 3) {
Operands.erase(Operands.begin(), Operands.begin() + 2);
Operands.insert(Operands.begin(), LanaiOperand::CreateToken("bt", NameLoc));
diff --git a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
index a421f3156153f..a366a89af8636 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
+++ b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
@@ -80,7 +80,7 @@ bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
// Global values placed in sections starting with .ldata do not fit in
// 21-bits, so always use large memory access for them. FIXME: This is a
// workaround for a tool limitation.
- if (GVA->getSection().startswith(".ldata"))
+ if (GVA->getSection().starts_with(".ldata"))
return false;
if (TM.getCodeModel() == CodeModel::Small)
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 61ec63ff6c1ca..4794a131edae0 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -4665,8 +4665,8 @@ LoongArchTargetLowering::getRegForInlineAsmConstraint(
// decode the usage of register name aliases into their official names. And
// AFAIK, the not yet upstreamed `rustc` for LoongArch will always use
// official register names.
- if (Constraint.startswith("{$r") || Constraint.startswith("{$f") ||
- Constraint.startswith("{$vr") || Constraint.startswith("{$xr")) {
+ if (Constraint.starts_with("{$r") || Constraint.starts_with("{$f") ||
+ Constraint.starts_with("{$vr") || Constraint.starts_with("{$xr")) {
bool IsFP = Constraint[2] == 'f';
std::pair<StringRef, StringRef> Temp = Constraint.split('$');
std::pair<unsigned, const TargetRegisterClass *> R;
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 60075c819b29c..3c673ae938fde 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -6249,7 +6249,7 @@ int MipsAsmParser::matchFPURegisterName(StringRef Name) {
}
int MipsAsmParser::matchFCCRegisterName(StringRef Name) {
- if (Name.startswith("fcc")) {
+ if (Name.starts_with("fcc")) {
StringRef NumString = Name.substr(3);
unsigned IntVal;
if (NumString.getAsInteger(10, IntVal))
@@ -6262,7 +6262,7 @@ int MipsAsmParser::matchFCCRegisterName(StringRef Name) {
}
int MipsAsmParser::matchACRegisterName(StringRef Name) {
- if (Name.startswith("ac")) {
+ if (Name.starts_with("ac")) {
StringRef NumString = Name.substr(2);
unsigned IntVal;
if (NumString.getAsInteger(10, IntVal))
@@ -6567,7 +6567,7 @@ bool MipsAsmParser::searchSymbolAlias(OperandVector &Operands) {
if (Expr->getKind() == MCExpr::SymbolRef) {
const MCSymbolRefExpr *Ref = static_cast<const MCSymbolRefExpr *>(Expr);
StringRef DefSymbol = Ref->getSymbol().getName();
- if (DefSymbol.startswith("$")) {
+ if (DefSymbol.starts_with("$")) {
ParseStatus Res =
matchAnyRegisterNameWithoutDollar(Operands, DefSymbol.substr(1), S);
if (Res.isSuccess()) {
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
index 81c1ccec7bede..94e3d28a41862 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
@@ -56,11 +56,11 @@ unsigned MipsABIInfo::GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const {
MipsABIInfo MipsABIInfo::computeTargetABI(const Triple &TT, StringRef CPU,
const MCTargetOptions &Options) {
- if (Options.getABIName().startswith("o32"))
+ if (Options.getABIName().starts_with("o32"))
return MipsABIInfo::O32();
- if (Options.getABIName().startswith("n32"))
+ if (Options.getABIName().starts_with("n32"))
return MipsABIInfo::N32();
- if (Options.getABIName().startswith("n64"))
+ if (Options.getABIName().starts_with("n64"))
return MipsABIInfo::N64();
if (TT.getEnvironment() == llvm::Triple::GNUABIN32)
return MipsABIInfo::N32();
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index f09d52aa5fd64..a0cab80243868 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -4064,7 +4064,7 @@ parseRegForInlineAsmConstraint(StringRef C, MVT VT) const {
RC = TRI->getRegClass(Prefix == "hi" ?
Mips::HI32RegClassID : Mips::LO32RegClassID);
return std::make_pair(*(RC->begin()), RC);
- } else if (Prefix.startswith("$msa")) {
+ } else if (Prefix.starts_with("$msa")) {
// Parse $msa(ir|csr|access|save|modify|request|map|unmap)
// No numeric characters follow the name.
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 5ced4129ee802..6a03c7b0abc34 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1016,8 +1016,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
}
// Skip LLVM intrinsic global variables
- if (GVar->getName().startswith("llvm.") ||
- GVar->getName().startswith("nvvm."))
+ if (GVar->getName().starts_with("llvm.") ||
+ GVar->getName().starts_with("nvvm."))
return;
const DataLayout &DL = getDataLayout();
diff --git a/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp b/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
index 4f03e474edb47..3d6bd1d8ad06b 100644
--- a/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
@@ -62,7 +62,7 @@ bool GenericToNVVM::runOnModule(Module &M) {
for (GlobalVariable &GV : llvm::make_early_inc_range(M.globals())) {
if (GV.getType()->getAddressSpace() == llvm::ADDRESS_SPACE_GENERIC &&
!llvm::isTexture(GV) && !llvm::isSurface(GV) && !llvm::isSampler(GV) &&
- !GV.getName().startswith("llvm.")) {
+ !GV.getName().starts_with("llvm.")) {
GlobalVariable *NewGV = new GlobalVariable(
M, GV.getValueType(), GV.isConstant(), GV.getLinkage(),
GV.hasInitializer() ? GV.getInitializer() : nullptr, "", &GV,
diff --git a/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp b/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
index 4bd820e98f050..85f75df39c0d0 100644
--- a/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
@@ -1812,7 +1812,7 @@ findIndexForHandle(MachineOperand &Op, MachineFunction &MF, unsigned &Idx) {
StringRef Sym = TexHandleDef.getOperand(6).getSymbolName();
std::string ParamBaseName = std::string(MF.getName());
ParamBaseName += "_param_";
- assert(Sym.startswith(ParamBaseName) && "Invalid symbol reference");
+ assert(Sym.starts_with(ParamBaseName) && "Invalid symbol reference");
unsigned Param = atoi(Sym.data()+ParamBaseName.size());
std::string NewSym;
raw_string_ostream NewSymStr(NewSym);
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index a33f44542eb5c..8108cfa521c80 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -1744,7 +1744,7 @@ bool PPCAsmParser::ParseDirective(AsmToken DirectiveID) {
ParseDirectiveAbiVersion(DirectiveID.getLoc());
else if (IDVal == ".localentry")
ParseDirectiveLocalEntry(DirectiveID.getLoc());
- else if (IDVal.startswith(".gnu_attribute"))
+ else if (IDVal.starts_with(".gnu_attribute"))
ParseGNUAttribute(DirectiveID.getLoc());
else
return true;
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 4b551bc51c4f0..780b22b4fbe65 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -2519,7 +2519,7 @@ void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
}
void PPCAIXAsmPrinter::emitGlobalVariableHelper(const GlobalVariable *GV) {
- assert(!GV->getName().startswith("llvm.") &&
+ assert(!GV->getName().starts_with("llvm.") &&
"Unhandled intrinsic global variable.");
if (GV->hasComdat())
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index b09975172bf5e..d676fa86a10e7 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -242,9 +242,9 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
const TargetOptions &Options) {
- if (Options.MCOptions.getABIName().startswith("elfv1"))
+ if (Options.MCOptions.getABIName().starts_with("elfv1"))
return PPCTargetMachine::PPC_ABI_ELFv1;
- else if (Options.MCOptions.getABIName().startswith("elfv2"))
+ else if (Options.MCOptions.getABIName().starts_with("elfv2"))
return PPCTargetMachine::PPC_ABI_ELFv2;
assert(Options.MCOptions.getABIName().empty() &&
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 138134d00f64a..f3ea0f597eec4 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -286,11 +286,11 @@ class RISCVAsmParser : public MCTargetAsmParser {
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
auto ABIName = StringRef(Options.ABIName);
- if (ABIName.endswith("f") && !getSTI().hasFeature(RISCV::FeatureStdExtF)) {
+ if (ABIName.ends_with("f") && !getSTI().hasFeature(RISCV::FeatureStdExtF)) {
errs() << "Hard-float 'f' ABI can't be used for a target that "
"doesn't support the F instruction set extension (ignoring "
"target-abi)\n";
- } else if (ABIName.endswith("d") &&
+ } else if (ABIName.ends_with("d") &&
!getSTI().hasFeature(RISCV::FeatureStdExtD)) {
errs() << "Hard-float 'd' ABI can't be used for a target that "
"doesn't support the D instruction set extension (ignoring "
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
index edcca8805dfc0..66a46a485f538 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
@@ -47,11 +47,11 @@ ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
errs()
<< "'" << ABIName
<< "' is not a recognized ABI for this target (ignoring target-abi)\n";
- } else if (ABIName.startswith("ilp32") && IsRV64) {
+ } else if (ABIName.starts_with("ilp32") && IsRV64) {
errs() << "32-bit ABIs are not supported for 64-bit targets (ignoring "
"target-abi)\n";
TargetABI = ABI_Unknown;
- } else if (ABIName.startswith("lp64") && !IsRV64) {
+ } else if (ABIName.starts_with("lp64") && !IsRV64) {
errs() << "64-bit ABIs are not supported for 32-bit targets (ignoring "
"target-abi)\n";
TargetABI = ABI_Unknown;
diff --git a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
index c16004e2fea21..a58e8e0dfedfa 100644
--- a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
+++ b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
@@ -1203,7 +1203,7 @@ ParseStatus SystemZAsmParser::parseDirective(AsmToken DirectiveID) {
return ParseDirectiveInsn(DirectiveID.getLoc());
if (IDVal == ".machine")
return ParseDirectiveMachine(DirectiveID.getLoc());
- if (IDVal.startswith(".gnu_attribute"))
+ if (IDVal.starts_with(".gnu_attribute"))
return ParseGNUAttribute(DirectiveID.getLoc());
return ParseStatus::NoMatch;
diff --git a/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp b/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
index 19dd6c83b750c..42287758c962d 100644
--- a/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
+++ b/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
@@ -923,31 +923,31 @@ StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
(Name[Next + 1] == 'd' || Name[Next + 1] == 's'))
ICC = false;
Mnemonic = parseCC(Name, Start, Next, ICC, true, NameLoc, Operands);
- } else if (Name.startswith("cmov.l.") || Name.startswith("cmov.w.") ||
- Name.startswith("cmov.d.") || Name.startswith("cmov.s.")) {
+ } else if (Name.starts_with("cmov.l.") || Name.starts_with("cmov.w.") ||
+ Name.starts_with("cmov.d.") || Name.starts_with("cmov.s.")) {
bool ICC = Name[5] == 'l' || Name[5] == 'w';
Mnemonic = parseCC(Name, 7, Name.size(), ICC, false, NameLoc, Operands);
- } else if (Name.startswith("cvt.w.d.sx") || Name.startswith("cvt.w.d.zx") ||
- Name.startswith("cvt.w.s.sx") || Name.startswith("cvt.w.s.zx")) {
+ } else if (Name.starts_with("cvt.w.d.sx") || Name.starts_with("cvt.w.d.zx") ||
+ Name.starts_with("cvt.w.s.sx") || Name.starts_with("cvt.w.s.zx")) {
Mnemonic = parseRD(Name, 10, NameLoc, Operands);
- } else if (Name.startswith("cvt.l.d")) {
+ } else if (Name.starts_with("cvt.l.d")) {
Mnemonic = parseRD(Name, 7, NameLoc, Operands);
- } else if (Name.startswith("vcvt.w.d.sx") || Name.startswith("vcvt.w.d.zx") ||
- Name.startswith("vcvt.w.s.sx") || Name.startswith("vcvt.w.s.zx")) {
+ } else if (Name.starts_with("vcvt.w.d.sx") || Name.starts_with("vcvt.w.d.zx") ||
+ Name.starts_with("vcvt.w.s.sx") || Name.starts_with("vcvt.w.s.zx")) {
Mnemonic = parseRD(Name, 11, NameLoc, Operands);
- } else if (Name.startswith("vcvt.l.d")) {
+ } else if (Name.starts_with("vcvt.l.d")) {
Mnemonic = parseRD(Name, 8, NameLoc, Operands);
- } else if (Name.startswith("pvcvt.w.s.lo") ||
- Name.startswith("pvcvt.w.s.up")) {
+ } else if (Name.starts_with("pvcvt.w.s.lo") ||
+ Name.starts_with("pvcvt.w.s.up")) {
Mnemonic = parseRD(Name, 12, NameLoc, Operands);
- } else if (Name.startswith("pvcvt.w.s")) {
+ } else if (Name.starts_with("pvcvt.w.s")) {
Mnemonic = parseRD(Name, 9, NameLoc, Operands);
- } else if (Name.startswith("vfmk.l.") || Name.startswith("vfmk.w.") ||
- Name.startswith("vfmk.d.") || Name.startswith("vfmk.s.")) {
+ } else if (Name.starts_with("vfmk.l.") || Name.starts_with("vfmk.w.") ||
+ Name.starts_with("vfmk.d.") || Name.starts_with("vfmk.s.")) {
bool ICC = Name[5] == 'l' || Name[5] == 'w' ? true : false;
Mnemonic = parseCC(Name, 7, Name.size(), ICC, true, NameLoc, Operands);
- } else if (Name.startswith("pvfmk.w.lo.") || Name.startswith("pvfmk.w.up.") ||
- Name.startswith("pvfmk.s.lo.") || Name.startswith("pvfmk.s.up.")) {
+ } else if (Name.starts_with("pvfmk.w.lo.") || Name.starts_with("pvfmk.w.up.") ||
+ Name.starts_with("pvfmk.s.lo.") || Name.starts_with("pvfmk.s.up.")) {
bool ICC = Name[6] == 'l' || Name[6] == 'w' ? true : false;
Mnemonic = parseCC(Name, 11, Name.size(), ICC, true, NameLoc, Operands);
} else {
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
index b70fa957a8599..1b92997f03f11 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -1103,7 +1103,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
// object writer expects each function to have its own section. This way
// The user can't forget this "convention".
auto SymName = Symbol->getName();
- if (SymName.startswith(".L"))
+ if (SymName.starts_with(".L"))
return; // Local Symbol.
// TODO: If the user explicitly creates a new function section, we ignore
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index 2c1ec21ba17d0..908efbb8d3215 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -104,7 +104,7 @@ WebAssemblyTargetStreamer *WebAssemblyAsmPrinter::getTargetStreamer() {
static bool isEmscriptenInvokeName(StringRef Name) {
if (Name.front() == '"' && Name.back() == '"')
Name = Name.substr(1, Name.size() - 2);
- return Name.startswith("__invoke_");
+ return Name.starts_with("__invoke_");
}
// Returns a character that represents the given wasm value type in invoke
@@ -235,7 +235,7 @@ MCSymbol *WebAssemblyAsmPrinter::getOrCreateWasmSymbol(StringRef Name) {
return WasmSym;
}
- if (Name.startswith("GCC_except_table")) {
+ if (Name.starts_with("GCC_except_table")) {
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_DATA);
return WasmSym;
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 5e84fff351b23..77e6640d5a822 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -623,7 +623,7 @@ static bool canLongjmp(const Value *Callee) {
return false;
// __cxa_find_matching_catch_N functions cannot longjmp
- if (Callee->getName().startswith("__cxa_find_matching_catch_"))
+ if (Callee->getName().starts_with("__cxa_find_matching_catch_"))
return false;
// Exception-catching related functions
@@ -1517,7 +1517,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForEmscriptenSjLj(
Value *Threw = nullptr;
BasicBlock *Tail;
- if (Callee->getName().startswith("__invoke_")) {
+ if (Callee->getName().starts_with("__invoke_")) {
// If invoke wrapper has already been generated for this call in
// previous EH phase, search for the load instruction
// %__THREW__.val = __THREW__;
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 32ede8558efe6..a01d710d6a4f9 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1417,7 +1417,7 @@ bool X86AsmParser::MatchRegisterByName(MCRegister &RegNo, StringRef RegName,
// If this is "db[0-15]", match it as an alias
// for dr[0-15].
- if (RegNo == 0 && RegName.startswith("db")) {
+ if (RegNo == 0 && RegName.starts_with("db")) {
if (RegName.size() == 3) {
switch (RegName[2]) {
case '0':
@@ -2072,7 +2072,7 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
Lex(); // eat type
bool EndDot = parseOptionalToken(AsmToken::Dot);
while (EndDot || (getTok().is(AsmToken::Identifier) &&
- getTok().getString().startswith("."))) {
+ getTok().getString().starts_with("."))) {
getParser().parseIdentifier(Identifier);
if (!EndDot)
Identifier.consume_front(".");
@@ -2271,7 +2271,7 @@ bool X86AsmParser::ParseRoundingModeOp(SMLoc Start, OperandVector &Operands) {
const SMLoc consumedToken = consumeToken();
if (Tok.isNot(AsmToken::Identifier))
return Error(Tok.getLoc(), "Expected an identifier after {");
- if (Tok.getIdentifier().startswith("r")){
+ if (Tok.getIdentifier().starts_with("r")) {
int rndMode = StringSwitch<int>(Tok.getIdentifier())
.Case("rn", X86::STATIC_ROUNDING::TO_NEAREST_INT)
.Case("rd", X86::STATIC_ROUNDING::TO_NEG_INF)
@@ -2313,7 +2313,7 @@ bool X86AsmParser::ParseIntelDotOperator(IntelExprStateMachine &SM,
// Drop the optional '.'.
StringRef DotDispStr = Tok.getString();
- if (DotDispStr.startswith("."))
+ if (DotDispStr.starts_with("."))
DotDispStr = DotDispStr.drop_front(1);
StringRef TrailingDot;
@@ -2325,7 +2325,7 @@ bool X86AsmParser::ParseIntelDotOperator(IntelExprStateMachine &SM,
Info.Offset = DotDisp.getZExtValue();
} else if ((isParsingMSInlineAsm() || getParser().isParsingMasm()) &&
Tok.is(AsmToken::Identifier)) {
- if (DotDispStr.endswith(".")) {
+ if (DotDispStr.ends_with(".")) {
TrailingDot = DotDispStr.substr(DotDispStr.size() - 1);
DotDispStr = DotDispStr.drop_back(1);
}
@@ -2815,7 +2815,7 @@ bool X86AsmParser::HandleAVX512Operand(OperandVector &Operands) {
SmallVector<char, 5> BroadcastVector;
StringRef BroadcastString = (Prefix + getLexer().getTok().getIdentifier())
.toStringRef(BroadcastVector);
- if (!BroadcastString.startswith("1to"))
+ if (!BroadcastString.starts_with("1to"))
return TokError("Expected 1to<NUM> at this point");
const char *BroadcastPrimitive =
StringSwitch<const char *>(BroadcastString)
@@ -3174,7 +3174,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
if (isParsingIntelSyntax() &&
(PatchedName == "jmp" || PatchedName == "jc" || PatchedName == "jnc" ||
PatchedName == "jcxz" || PatchedName == "jecxz" ||
- (PatchedName.startswith("j") &&
+ (PatchedName.starts_with("j") &&
ParseConditionCode(PatchedName.substr(1)) != X86::COND_INVALID))) {
StringRef NextTok = Parser.getTok().getString();
if (Parser.isParsingMasm() ? NextTok.equals_insensitive("short")
@@ -3192,17 +3192,17 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// FIXME: Hack to recognize setneb as setne.
- if (PatchedName.startswith("set") && PatchedName.endswith("b") &&
+ if (PatchedName.starts_with("set") && PatchedName.ends_with("b") &&
PatchedName != "setb" && PatchedName != "setnb")
PatchedName = PatchedName.substr(0, Name.size()-1);
unsigned ComparisonPredicate = ~0U;
// FIXME: Hack to recognize cmp<comparison code>{sh,ss,sd,ph,ps,pd}.
- if ((PatchedName.startswith("cmp") || PatchedName.startswith("vcmp")) &&
- (PatchedName.endswith("ss") || PatchedName.endswith("sd") ||
- PatchedName.endswith("sh") || PatchedName.endswith("ph") ||
- PatchedName.endswith("ps") || PatchedName.endswith("pd"))) {
+ if ((PatchedName.starts_with("cmp") || PatchedName.starts_with("vcmp")) &&
+ (PatchedName.ends_with("ss") || PatchedName.ends_with("sd") ||
+ PatchedName.ends_with("sh") || PatchedName.ends_with("ph") ||
+ PatchedName.ends_with("ps") || PatchedName.ends_with("pd"))) {
bool IsVCMP = PatchedName[0] == 'v';
unsigned CCIdx = IsVCMP ? 4 : 3;
unsigned CC = StringSwitch<unsigned>(
@@ -3257,17 +3257,17 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
.Default(~0U);
if (CC != ~0U && (IsVCMP || CC < 8) &&
(IsVCMP || PatchedName.back() != 'h')) {
- if (PatchedName.endswith("ss"))
+ if (PatchedName.ends_with("ss"))
PatchedName = IsVCMP ? "vcmpss" : "cmpss";
- else if (PatchedName.endswith("sd"))
+ else if (PatchedName.ends_with("sd"))
PatchedName = IsVCMP ? "vcmpsd" : "cmpsd";
- else if (PatchedName.endswith("ps"))
+ else if (PatchedName.ends_with("ps"))
PatchedName = IsVCMP ? "vcmpps" : "cmpps";
- else if (PatchedName.endswith("pd"))
+ else if (PatchedName.ends_with("pd"))
PatchedName = IsVCMP ? "vcmppd" : "cmppd";
- else if (PatchedName.endswith("sh"))
+ else if (PatchedName.ends_with("sh"))
PatchedName = "vcmpsh";
- else if (PatchedName.endswith("ph"))
+ else if (PatchedName.ends_with("ph"))
PatchedName = "vcmpph";
else
llvm_unreachable("Unexpected suffix!");
@@ -3277,7 +3277,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// FIXME: Hack to recognize vpcmp<comparison code>{ub,uw,ud,uq,b,w,d,q}.
- if (PatchedName.startswith("vpcmp") &&
+ if (PatchedName.starts_with("vpcmp") &&
(PatchedName.back() == 'b' || PatchedName.back() == 'w' ||
PatchedName.back() == 'd' || PatchedName.back() == 'q')) {
unsigned SuffixSize = PatchedName.drop_back().back() == 'u' ? 2 : 1;
@@ -3306,7 +3306,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// FIXME: Hack to recognize vpcom<comparison code>{ub,uw,ud,uq,b,w,d,q}.
- if (PatchedName.startswith("vpcom") &&
+ if (PatchedName.starts_with("vpcom") &&
(PatchedName.back() == 'b' || PatchedName.back() == 'w' ||
PatchedName.back() == 'd' || PatchedName.back() == 'q')) {
unsigned SuffixSize = PatchedName.drop_back().back() == 'u' ? 2 : 1;
@@ -3380,9 +3380,9 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
Parser.Lex(); // eat the prefix
// Hack: we could have something like "rep # some comment" or
// "lock; cmpxchg16b $1" or "lock\0A\09incl" or "lock/incl"
- while (Name.startswith(";") || Name.startswith("\n") ||
- Name.startswith("#") || Name.startswith("\t") ||
- Name.startswith("/")) {
+ while (Name.starts_with(";") || Name.starts_with("\n") ||
+ Name.starts_with("#") || Name.starts_with("\t") ||
+ Name.starts_with("/")) {
// FIXME: The mnemonic won't match correctly if its not in lower case.
Name = Parser.getTok().getString();
Parser.Lex(); // go to next prefix or instr
@@ -3541,7 +3541,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
bool HadVerifyError = false;
// Append default arguments to "ins[bwld]"
- if (Name.startswith("ins") &&
+ if (Name.starts_with("ins") &&
(Operands.size() == 1 || Operands.size() == 3) &&
(Name == "insb" || Name == "insw" || Name == "insl" || Name == "insd" ||
Name == "ins")) {
@@ -3553,7 +3553,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// Append default arguments to "outs[bwld]"
- if (Name.startswith("outs") &&
+ if (Name.starts_with("outs") &&
(Operands.size() == 1 || Operands.size() == 3) &&
(Name == "outsb" || Name == "outsw" || Name == "outsl" ||
Name == "outsd" || Name == "outs")) {
@@ -3565,7 +3565,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// Transform "lods[bwlq]" into "lods[bwlq] ($SIREG)" for appropriate
// values of $SIREG according to the mode. It would be nice if this
// could be achieved with InstAlias in the tables.
- if (Name.startswith("lods") &&
+ if (Name.starts_with("lods") &&
(Operands.size() == 1 || Operands.size() == 2) &&
(Name == "lods" || Name == "lodsb" || Name == "lodsw" ||
Name == "lodsl" || Name == "lodsd" || Name == "lodsq")) {
@@ -3576,7 +3576,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// Transform "stos[bwlq]" into "stos[bwlq] ($DIREG)" for appropriate
// values of $DIREG according to the mode. It would be nice if this
// could be achieved with InstAlias in the tables.
- if (Name.startswith("stos") &&
+ if (Name.starts_with("stos") &&
(Operands.size() == 1 || Operands.size() == 2) &&
(Name == "stos" || Name == "stosb" || Name == "stosw" ||
Name == "stosl" || Name == "stosd" || Name == "stosq")) {
@@ -3587,7 +3587,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// Transform "scas[bwlq]" into "scas[bwlq] ($DIREG)" for appropriate
// values of $DIREG according to the mode. It would be nice if this
// could be achieved with InstAlias in the tables.
- if (Name.startswith("scas") &&
+ if (Name.starts_with("scas") &&
(Operands.size() == 1 || Operands.size() == 2) &&
(Name == "scas" || Name == "scasb" || Name == "scasw" ||
Name == "scasl" || Name == "scasd" || Name == "scasq")) {
@@ -3596,7 +3596,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// Add default SI and DI operands to "cmps[bwlq]".
- if (Name.startswith("cmps") &&
+ if (Name.starts_with("cmps") &&
(Operands.size() == 1 || Operands.size() == 3) &&
(Name == "cmps" || Name == "cmpsb" || Name == "cmpsw" ||
Name == "cmpsl" || Name == "cmpsd" || Name == "cmpsq")) {
@@ -3606,10 +3606,10 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// Add default SI and DI operands to "movs[bwlq]".
- if (((Name.startswith("movs") &&
+ if (((Name.starts_with("movs") &&
(Name == "movs" || Name == "movsb" || Name == "movsw" ||
Name == "movsl" || Name == "movsd" || Name == "movsq")) ||
- (Name.startswith("smov") &&
+ (Name.starts_with("smov") &&
(Name == "smov" || Name == "smovb" || Name == "smovw" ||
Name == "smovl" || Name == "smovd" || Name == "smovq"))) &&
(Operands.size() == 1 || Operands.size() == 3)) {
@@ -4472,11 +4472,11 @@ bool X86AsmParser::OmitRegisterFromClobberLists(unsigned RegNo) {
bool X86AsmParser::ParseDirective(AsmToken DirectiveID) {
MCAsmParser &Parser = getParser();
StringRef IDVal = DirectiveID.getIdentifier();
- if (IDVal.startswith(".arch"))
+ if (IDVal.starts_with(".arch"))
return parseDirectiveArch();
- if (IDVal.startswith(".code"))
+ if (IDVal.starts_with(".code"))
return ParseDirectiveCode(IDVal, DirectiveID.getLoc());
- else if (IDVal.startswith(".att_syntax")) {
+ else if (IDVal.starts_with(".att_syntax")) {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
if (Parser.getTok().getString() == "prefix")
Parser.Lex();
@@ -4487,7 +4487,7 @@ bool X86AsmParser::ParseDirective(AsmToken DirectiveID) {
}
getParser().setAssemblerDialect(0);
return false;
- } else if (IDVal.startswith(".intel_syntax")) {
+ } else if (IDVal.starts_with(".intel_syntax")) {
getParser().setAssemblerDialect(1);
if (getLexer().isNot(AsmToken::EndOfStatement)) {
if (Parser.getTok().getString() == "noprefix")
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 165e9207ef1c2..ed4d0a45bd8f2 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -399,8 +399,8 @@ MCSubtargetInfo *X86_MC::createX86MCSubtargetInfo(const Triple &TT,
size_t posNoEVEX512 = FS.rfind("-evex512");
// Make sure we won't be cheated by "-avx512fp16".
- size_t posNoAVX512F = FS.endswith("-avx512f") ? FS.size() - 8
- : FS.rfind("-avx512f,");
+ size_t posNoAVX512F =
+ FS.ends_with("-avx512f") ? FS.size() - 8 : FS.rfind("-avx512f,");
size_t posEVEX512 = FS.rfind("+evex512");
size_t posAVX512F = FS.rfind("+avx512"); // Any AVX512XXX will enable AVX512F.
diff --git a/llvm/lib/Target/X86/X86InsertPrefetch.cpp b/llvm/lib/Target/X86/X86InsertPrefetch.cpp
index 3c9738be547f3..3e11ab2d98a44 100644
--- a/llvm/lib/Target/X86/X86InsertPrefetch.cpp
+++ b/llvm/lib/Target/X86/X86InsertPrefetch.cpp
@@ -135,7 +135,7 @@ bool X86InsertPrefetch::findPrefetchInfo(const FunctionSamples *TopSamples,
int64_t D = static_cast<int64_t>(S_V.second);
unsigned IID = 0;
for (const auto &HintType : HintTypes) {
- if (Name.startswith(HintType.first)) {
+ if (Name.starts_with(HintType.first)) {
Name = Name.drop_front(HintType.first.size());
IID = HintType.second;
break;
diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index 328608363a8fd..0f76daffd4633 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -267,8 +267,8 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
if (CPU == "generic" || CPU == "pentium4" || CPU == "x86-64") {
size_t posNoEVEX512 = FS.rfind("-evex512");
// Make sure we won't be cheated by "-avx512fp16".
- size_t posNoAVX512F = FS.endswith("-avx512f") ? FS.size() - 8
- : FS.rfind("-avx512f,");
+ size_t posNoAVX512F =
+ FS.ends_with("-avx512f") ? FS.size() - 8 : FS.rfind("-avx512f,");
size_t posEVEX512 = FS.rfind("+evex512");
// Any AVX512XXX will enable AVX512F.
size_t posAVX512F = FS.rfind("+avx512");
diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
index 80edad58985b9..7736adab19e89 100644
--- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
@@ -249,7 +249,7 @@ SDValue XCoreTargetLowering::getGlobalAddressWrapper(SDValue GA,
return DAG.getNode(XCoreISD::PCRelativeWrapper, dl, MVT::i32, GA);
const auto *GVar = dyn_cast<GlobalVariable>(GV);
- if ((GV->hasSection() && GV->getSection().startswith(".cp.")) ||
+ if ((GV->hasSection() && GV->getSection().starts_with(".cp.")) ||
(GVar && GVar->isConstant() && GV->hasLocalLinkage()))
return DAG.getNode(XCoreISD::CPRelativeWrapper, dl, MVT::i32, GA);
diff --git a/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp b/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp
index 52a0a09d3ea5f..ae697f43b0eed 100644
--- a/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp
+++ b/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp
@@ -98,7 +98,7 @@ MCSection *XCoreTargetObjectFile::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef SectionName = GO->getSection();
// Infer section flags from the section name if we can.
- bool IsCPRel = SectionName.startswith(".cp.");
+ bool IsCPRel = SectionName.starts_with(".cp.");
if (IsCPRel && !Kind.isReadOnly())
report_fatal_error("Using .cp. section for writeable object.");
return getContext().getELFSection(SectionName, getXCoreSectionType(Kind),
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index a3f9dfa4a283e..d3c72497c41cb 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -75,7 +75,7 @@ StringRef AArch64::resolveCPUAlias(StringRef Name) {
}
StringRef AArch64::getArchExtFeature(StringRef ArchExt) {
- if (ArchExt.startswith("no")) {
+ if (ArchExt.starts_with("no")) {
StringRef ArchExtBase(ArchExt.substr(2));
for (const auto &AE : Extensions) {
if (!AE.NegFeature.empty() && ArchExtBase == AE.Name)
@@ -110,7 +110,7 @@ std::optional<AArch64::ArchInfo> AArch64::parseArch(StringRef Arch) {
StringRef Syn = llvm::ARM::getArchSynonym(Arch);
for (const auto *A : ArchInfos) {
- if (A->Name.endswith(Syn))
+ if (A->Name.ends_with(Syn))
return *A;
}
return {};
diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp b/llvm/lib/TargetParser/ARMTargetParser.cpp
index d09992441909e..27d168020ce60 100644
--- a/llvm/lib/TargetParser/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -32,7 +32,7 @@ ARM::ArchKind ARM::parseArch(StringRef Arch) {
Arch = getCanonicalArchName(Arch);
StringRef Syn = getArchSynonym(Arch);
for (const auto &A : ARMArchNames) {
- if (A.Name.endswith(Syn))
+ if (A.Name.ends_with(Syn))
return A.ID;
}
return ArchKind::INVALID;
@@ -348,7 +348,7 @@ StringRef ARM::getArchExtName(uint64_t ArchExtKind) {
}
static bool stripNegationPrefix(StringRef &Name) {
- if (Name.startswith("no")) {
+ if (Name.starts_with("no")) {
Name = Name.substr(2);
return true;
}
diff --git a/llvm/lib/TargetParser/ARMTargetParserCommon.cpp b/llvm/lib/TargetParser/ARMTargetParserCommon.cpp
index 907ee5957c7c9..10b80cad43472 100644
--- a/llvm/lib/TargetParser/ARMTargetParserCommon.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParserCommon.cpp
@@ -57,19 +57,19 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
StringRef Error = "";
// Begins with "arm" / "thumb", move past it.
- if (A.startswith("arm64_32"))
+ if (A.starts_with("arm64_32"))
offset = 8;
- else if (A.startswith("arm64e"))
+ else if (A.starts_with("arm64e"))
offset = 6;
- else if (A.startswith("arm64"))
+ else if (A.starts_with("arm64"))
offset = 5;
- else if (A.startswith("aarch64_32"))
+ else if (A.starts_with("aarch64_32"))
offset = 10;
- else if (A.startswith("arm"))
+ else if (A.starts_with("arm"))
offset = 3;
- else if (A.startswith("thumb"))
+ else if (A.starts_with("thumb"))
offset = 5;
- else if (A.startswith("aarch64")) {
+ else if (A.starts_with("aarch64")) {
offset = 7;
// AArch64 uses "_be", not "eb" suffix.
if (A.contains("eb"))
@@ -82,7 +82,7 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
if (offset != StringRef::npos && A.substr(offset, 2) == "eb")
offset += 2;
// Or, if it ends with eb ("armv7eb"), chop it off.
- else if (A.endswith("eb"))
+ else if (A.ends_with("eb"))
A = A.substr(0, A.size() - 2);
// Trim the head
if (offset != StringRef::npos)
@@ -116,18 +116,18 @@ ARM::ISAKind ARM::parseArchISA(StringRef Arch) {
}
ARM::EndianKind ARM::parseArchEndian(StringRef Arch) {
- if (Arch.startswith("armeb") || Arch.startswith("thumbeb") ||
- Arch.startswith("aarch64_be"))
+ if (Arch.starts_with("armeb") || Arch.starts_with("thumbeb") ||
+ Arch.starts_with("aarch64_be"))
return EndianKind::BIG;
- if (Arch.startswith("arm") || Arch.startswith("thumb")) {
- if (Arch.endswith("eb"))
+ if (Arch.starts_with("arm") || Arch.starts_with("thumb")) {
+ if (Arch.ends_with("eb"))
return EndianKind::BIG;
else
return EndianKind::LITTLE;
}
- if (Arch.startswith("aarch64") || Arch.startswith("aarch64_32"))
+ if (Arch.starts_with("aarch64") || Arch.starts_with("aarch64_32"))
return EndianKind::LITTLE;
return EndianKind::INVALID;
diff --git a/llvm/lib/TargetParser/CSKYTargetParser.cpp b/llvm/lib/TargetParser/CSKYTargetParser.cpp
index 493f253cd716b..006d2bb342acc 100644
--- a/llvm/lib/TargetParser/CSKYTargetParser.cpp
+++ b/llvm/lib/TargetParser/CSKYTargetParser.cpp
@@ -150,7 +150,7 @@ StringRef CSKY::getArchExtName(uint64_t ArchExtKind) {
}
static bool stripNegationPrefix(StringRef &Name) {
- if (Name.startswith("no")) {
+ if (Name.starts_with("no")) {
Name = Name.substr(2);
return true;
}
diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 40f4ba0be5503..e822da11ee85a 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -170,18 +170,18 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
StringRef Hardware;
StringRef Part;
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
- if (Lines[I].startswith("CPU implementer"))
+ if (Lines[I].starts_with("CPU implementer"))
Implementer = Lines[I].substr(15).ltrim("\t :");
- if (Lines[I].startswith("Hardware"))
+ if (Lines[I].starts_with("Hardware"))
Hardware = Lines[I].substr(8).ltrim("\t :");
- if (Lines[I].startswith("CPU part"))
+ if (Lines[I].starts_with("CPU part"))
Part = Lines[I].substr(8).ltrim("\t :");
}
if (Implementer == "0x41") { // ARM Ltd.
// MSM8992/8994 may give cpu part for the core that the kernel is running on,
// which is undeterministic and wrong. Always return cortex-a53 for these SoC.
- if (Hardware.endswith("MSM8994") || Hardware.endswith("MSM8996"))
+ if (Hardware.ends_with("MSM8994") || Hardware.ends_with("MSM8996"))
return "cortex-a53";
@@ -367,7 +367,7 @@ StringRef sys::detail::getHostCPUNameForS390x(StringRef ProcCpuinfoContent) {
// Look for the CPU features.
SmallVector<StringRef, 32> CPUFeatures;
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
- if (Lines[I].startswith("features")) {
+ if (Lines[I].starts_with("features")) {
size_t Pos = Lines[I].find(':');
if (Pos != StringRef::npos) {
Lines[I].drop_front(Pos + 1).split(CPUFeatures, ' ');
@@ -386,7 +386,7 @@ StringRef sys::detail::getHostCPUNameForS390x(StringRef ProcCpuinfoContent) {
// Now check the processor machine type.
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
- if (Lines[I].startswith("processor ")) {
+ if (Lines[I].starts_with("processor ")) {
size_t Pos = Lines[I].find("machine = ");
if (Pos != StringRef::npos) {
Pos += sizeof("machine = ") - 1;
@@ -409,7 +409,7 @@ StringRef sys::detail::getHostCPUNameForRISCV(StringRef ProcCpuinfoContent) {
// Look for uarch line to determine cpu name
StringRef UArch;
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
- if (Lines[I].startswith("uarch")) {
+ if (Lines[I].starts_with("uarch")) {
UArch = Lines[I].substr(5).ltrim("\t :");
break;
}
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d2258..ac04dab048971 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -477,7 +477,7 @@ static Triple::ArchType parseARMArch(StringRef ArchName) {
// Thumb only exists in v4+
if (ISA == ARM::ISAKind::THUMB &&
- (ArchName.startswith("v2") || ArchName.startswith("v3")))
+ (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
return Triple::UnknownArch;
// Thumb only for v6m
@@ -574,10 +574,10 @@ static Triple::ArchType parseArch(StringRef ArchName) {
// Some architectures require special parsing logic just to compute the
// ArchType result.
if (AT == Triple::UnknownArch) {
- if (ArchName.startswith("arm") || ArchName.startswith("thumb") ||
- ArchName.startswith("aarch64"))
+ if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
+ ArchName.starts_with("aarch64"))
return parseARMArch(ArchName);
- if (ArchName.startswith("bpf"))
+ if (ArchName.starts_with("bpf"))
return parseBPFArch(ArchName);
}
@@ -706,8 +706,8 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
}
static Triple::SubArchType parseSubArch(StringRef SubArchName) {
- if (SubArchName.startswith("mips") &&
- (SubArchName.endswith("r6el") || SubArchName.endswith("r6")))
+ if (SubArchName.starts_with("mips") &&
+ (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
return Triple::MipsSubArch_r6;
if (SubArchName == "powerpcspe")
@@ -719,7 +719,7 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
if (SubArchName == "arm64ec")
return Triple::AArch64SubArch_arm64ec;
- if (SubArchName.startswith("spirv"))
+ if (SubArchName.starts_with("spirv"))
return StringSwitch<Triple::SubArchType>(SubArchName)
.EndsWith("v1.0", Triple::SPIRVSubArch_v10)
.EndsWith("v1.1", Triple::SPIRVSubArch_v11)
@@ -1004,8 +1004,8 @@ std::string Triple::normalize(StringRef Str) {
OSType OS = UnknownOS;
if (Components.size() > 2) {
OS = parseOS(Components[2]);
- IsCygwin = Components[2].startswith("cygwin");
- IsMinGW32 = Components[2].startswith("mingw");
+ IsCygwin = Components[2].starts_with("cygwin");
+ IsMinGW32 = Components[2].starts_with("mingw");
}
EnvironmentType Environment = UnknownEnvironment;
if (Components.size() > 3)
@@ -1049,8 +1049,8 @@ std::string Triple::normalize(StringRef Str) {
break;
case 2:
OS = parseOS(Comp);
- IsCygwin = Comp.startswith("cygwin");
- IsMinGW32 = Comp.startswith("mingw");
+ IsCygwin = Comp.starts_with("cygwin");
+ IsMinGW32 = Comp.starts_with("mingw");
Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
break;
case 3:
@@ -1127,7 +1127,8 @@ std::string Triple::normalize(StringRef Str) {
// Special case logic goes here. At this point Arch, Vendor and OS have the
// correct values for the computed components.
std::string NormalizedEnvironment;
- if (Environment == Triple::Android && Components[3].startswith("androideabi")) {
+ if (Environment == Triple::Android &&
+ Components[3].starts_with("androideabi")) {
StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
if (AndroidVersion.empty()) {
Components[3] = "android";
@@ -1206,7 +1207,7 @@ static VersionTuple parseVersionFromName(StringRef Name) {
VersionTuple Triple::getEnvironmentVersion() const {
StringRef EnvironmentName = getEnvironmentName();
StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
- if (EnvironmentName.startswith(EnvironmentTypeName))
+ if (EnvironmentName.starts_with(EnvironmentTypeName))
EnvironmentName = EnvironmentName.substr(EnvironmentTypeName.size());
return parseVersionFromName(EnvironmentName);
@@ -1216,7 +1217,7 @@ VersionTuple Triple::getOSVersion() const {
StringRef OSName = getOSName();
// Assume that the OS portion of the triple starts with the canonical name.
StringRef OSTypeName = getOSTypeName(getOS());
- if (OSName.startswith(OSTypeName))
+ if (OSName.starts_with(OSTypeName))
OSName = OSName.substr(OSTypeName.size());
else if (getOS() == MacOSX)
OSName.consume_front("macos");
diff --git a/llvm/lib/TextAPI/Symbol.cpp b/llvm/lib/TextAPI/Symbol.cpp
index c3756fcb84355..fd395436051d3 100644
--- a/llvm/lib/TextAPI/Symbol.cpp
+++ b/llvm/lib/TextAPI/Symbol.cpp
@@ -73,16 +73,16 @@ bool Symbol::operator==(const Symbol &O) const {
}
SimpleSymbol parseSymbol(StringRef SymName, const SymbolFlags Flags) {
- if (SymName.startswith(ObjC1ClassNamePrefix))
+ if (SymName.starts_with(ObjC1ClassNamePrefix))
return {SymName.drop_front(ObjC1ClassNamePrefix.size()),
SymbolKind::ObjectiveCClass};
- if (SymName.startswith(ObjC2ClassNamePrefix))
+ if (SymName.starts_with(ObjC2ClassNamePrefix))
return {SymName.drop_front(ObjC2ClassNamePrefix.size()),
SymbolKind::ObjectiveCClass};
- if (SymName.startswith(ObjC2MetaClassNamePrefix))
+ if (SymName.starts_with(ObjC2MetaClassNamePrefix))
return {SymName.drop_front(ObjC2MetaClassNamePrefix.size()),
SymbolKind::ObjectiveCClass};
- if (SymName.startswith(ObjC2EHTypePrefix)) {
+ if (SymName.starts_with(ObjC2EHTypePrefix)) {
// When classes without ehtype are used in try/catch blocks
// a weak-defined symbol is exported. In those cases, treat these as a
// global instead.
@@ -92,7 +92,7 @@ SimpleSymbol parseSymbol(StringRef SymName, const SymbolFlags Flags) {
SymbolKind::ObjectiveCClassEHType};
}
- if (SymName.startswith(ObjC2IVarPrefix))
+ if (SymName.starts_with(ObjC2IVarPrefix))
return {SymName.drop_front(ObjC2IVarPrefix.size()),
SymbolKind::ObjectiveCInstanceVariable};
return {SymName, SymbolKind::GlobalSymbol};
diff --git a/llvm/lib/TextAPI/Target.cpp b/llvm/lib/TextAPI/Target.cpp
index 7f45519735074..a50abeeca194c 100644
--- a/llvm/lib/TextAPI/Target.cpp
+++ b/llvm/lib/TextAPI/Target.cpp
@@ -28,7 +28,7 @@ Expected<Target> Target::create(StringRef TargetValue) {
.Default(PLATFORM_UNKNOWN);
if (Platform == PLATFORM_UNKNOWN) {
- if (PlatformStr.startswith("<") && PlatformStr.endswith(">")) {
+ if (PlatformStr.starts_with("<") && PlatformStr.ends_with(">")) {
PlatformStr = PlatformStr.drop_front().drop_back();
unsigned long long RawValue;
if (!PlatformStr.getAsInteger(10, RawValue))
diff --git a/llvm/lib/TextAPI/TextStub.cpp b/llvm/lib/TextAPI/TextStub.cpp
index 635f6b3a3df6d..9fa1459e95570 100644
--- a/llvm/lib/TextAPI/TextStub.cpp
+++ b/llvm/lib/TextAPI/TextStub.cpp
@@ -614,7 +614,7 @@ template <> struct MappingTraits<const InterfaceFile *> {
for (const auto &Symbol : Section.Symbols) {
if (Ctx->FileKind != FileType::TBD_V3 &&
- Symbol.value.startswith(ObjC2EHTypePrefix))
+ Symbol.value.starts_with(ObjC2EHTypePrefix))
File->addSymbol(SymbolKind::ObjectiveCClassEHType,
Symbol.value.drop_front(15), Targets, Flags);
else
@@ -649,7 +649,7 @@ template <> struct MappingTraits<const InterfaceFile *> {
synthesizeTargets(Section.Architectures, Platforms);
for (auto &Symbol : Section.Symbols) {
if (Ctx->FileKind != FileType::TBD_V3 &&
- Symbol.value.startswith(ObjC2EHTypePrefix))
+ Symbol.value.starts_with(ObjC2EHTypePrefix))
File->addSymbol(SymbolKind::ObjectiveCClassEHType,
Symbol.value.drop_front(15), Targets,
SymbolFlags::Undefined | Flags);
@@ -1073,23 +1073,23 @@ static void DiagHandler(const SMDiagnostic &Diag, void *Context) {
Expected<FileType> TextAPIReader::canRead(MemoryBufferRef InputBuffer) {
auto TAPIFile = InputBuffer.getBuffer().trim();
- if (TAPIFile.startswith("{") && TAPIFile.endswith("}"))
+ if (TAPIFile.starts_with("{") && TAPIFile.ends_with("}"))
return FileType::TBD_V5;
- if (!TAPIFile.endswith("..."))
+ if (!TAPIFile.ends_with("..."))
return createStringError(std::errc::not_supported, "unsupported file type");
- if (TAPIFile.startswith("--- !tapi-tbd\n"))
+ if (TAPIFile.starts_with("--- !tapi-tbd\n"))
return FileType::TBD_V4;
- if (TAPIFile.startswith("--- !tapi-tbd-v3\n"))
+ if (TAPIFile.starts_with("--- !tapi-tbd-v3\n"))
return FileType::TBD_V3;
- if (TAPIFile.startswith("--- !tapi-tbd-v2\n"))
+ if (TAPIFile.starts_with("--- !tapi-tbd-v2\n"))
return FileType::TBD_V2;
- if (TAPIFile.startswith("--- !tapi-tbd-v1\n") ||
- TAPIFile.startswith("---\narchs:"))
+ if (TAPIFile.starts_with("--- !tapi-tbd-v1\n") ||
+ TAPIFile.starts_with("---\narchs:"))
return FileType::TBD_V1;
return createStringError(std::errc::not_supported, "unsupported file type");
diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp
index c19285eebdd74..646fe4fc8f804 100644
--- a/llvm/tools/dsymutil/BinaryHolder.cpp
+++ b/llvm/tools/dsymutil/BinaryHolder.cpp
@@ -26,7 +26,7 @@ getArchiveAndObjectName(StringRef Filename) {
return {Archive, Object};
}
-static bool isArchive(StringRef Filename) { return Filename.endswith(")"); }
+static bool isArchive(StringRef Filename) { return Filename.ends_with(")"); }
static std::vector<MemoryBufferRef>
getMachOFatMemoryBuffers(StringRef Filename, MemoryBuffer &Mem,
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index d00ef1a8c228b..33d053c745b0c 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -164,7 +164,7 @@ DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj,
static Error remarksErrorHandler(const DebugMapObject &DMO,
DwarfLinkerForBinary &Linker,
std::unique_ptr<FileError> FE) {
- bool IsArchive = DMO.getObjectFilename().endswith(")");
+ bool IsArchive = DMO.getObjectFilename().ends_with(")");
// Don't report errors for missing remark files from static
// archives.
if (!IsArchive)
@@ -713,7 +713,7 @@ bool DwarfLinkerForBinary::linkImpl(
// Try and emit more helpful warnings by applying some heuristics.
StringRef ObjFile = ContainerName;
bool IsClangModule = sys::path::extension(Path).equals(".pcm");
- bool IsArchive = ObjFile.endswith(")");
+ bool IsArchive = ObjFile.ends_with(")");
if (IsClangModule) {
StringRef ModuleCacheDir = sys::path::parent_path(Path);
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 9623b71714582..7a32eacee14c1 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -550,11 +550,11 @@ static bool shouldLinkArch(SmallVectorImpl<StringRef> &Archs, StringRef Arch) {
if (Archs.empty() || is_contained(Archs, "all") || is_contained(Archs, "*"))
return true;
- if (Arch.startswith("arm") && Arch != "arm64" && is_contained(Archs, "arm"))
+ if (Arch.starts_with("arm") && Arch != "arm64" && is_contained(Archs, "arm"))
return true;
SmallString<16> ArchName = Arch;
- if (Arch.startswith("thumb"))
+ if (Arch.starts_with("thumb"))
ArchName = ("arm" + Arch.substr(5)).str();
return is_contained(Archs, ArchName);
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index 44c925fce5c2b..3efc1aff82374 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -57,7 +57,7 @@ ArchAndFile::~ArchAndFile() {
}
std::string getArchName(StringRef Arch) {
- if (Arch.startswith("thumb"))
+ if (Arch.starts_with("thumb"))
return (llvm::Twine("arm") + Arch.drop_front(5)).str();
return std::string(Arch);
}
diff --git a/llvm/tools/dsymutil/SymbolMap.cpp b/llvm/tools/dsymutil/SymbolMap.cpp
index 07a54795a8418..0cf8b983db1fc 100644
--- a/llvm/tools/dsymutil/SymbolMap.cpp
+++ b/llvm/tools/dsymutil/SymbolMap.cpp
@@ -23,7 +23,7 @@ namespace llvm {
namespace dsymutil {
StringRef SymbolMapTranslator::operator()(StringRef Input) {
- if (!Input.startswith("__hidden#") && !Input.startswith("___hidden#"))
+ if (!Input.starts_with("__hidden#") && !Input.starts_with("___hidden#"))
return Input;
bool MightNeedUnderscore = false;
@@ -131,7 +131,7 @@ SymbolMapTranslator SymbolMapLoader::Load(StringRef InputFile,
bool MangleNames = false;
// Check version string first.
- if (!LHS.startswith("BCSymbolMap Version:")) {
+ if (!LHS.starts_with("BCSymbolMap Version:")) {
// Version string not present, warns but try to parse it.
WithColor::warning() << SymbolMapPath
<< " is missing version string: assuming 1.0.\n";
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 34e563399813f..8d906cf372878 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -249,9 +249,9 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
else {
// If InputFilename ends in .bc or .ll, remove it.
StringRef IFN = InputFilename;
- if (IFN.endswith(".bc") || IFN.endswith(".ll"))
+ if (IFN.ends_with(".bc") || IFN.ends_with(".ll"))
OutputFilename = std::string(IFN.drop_back(3));
- else if (IFN.endswith(".mir"))
+ else if (IFN.ends_with(".mir"))
OutputFilename = std::string(IFN.drop_back(4));
else
OutputFilename = std::string(IFN);
@@ -584,7 +584,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
return Target->createDataLayout().getStringRepresentation();
};
if (InputLanguage == "mir" ||
- (InputLanguage == "" && StringRef(InputFilename).endswith(".mir"))) {
+ (InputLanguage == "" && StringRef(InputFilename).ends_with(".mir"))) {
MIR = createMIRParserFromFile(InputFilename, Err, Context,
setMIRFunctionAttributes);
if (MIR)
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 36fca4c40ed06..5f1fd15787642 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -622,7 +622,7 @@ int main(int argc, char **argv, char * const *envp) {
} else {
// Otherwise, if there is a .bc suffix on the executable strip it off, it
// might confuse the program.
- if (StringRef(InputFile).endswith(".bc"))
+ if (StringRef(InputFile).ends_with(".bc"))
InputFile.erase(InputFile.length() - 3);
}
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index 9889ad9de627d..fcb6392a1d955 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -1287,7 +1287,7 @@ static const char *matchFlagWithArg(StringRef Expected,
ArrayRef<const char *> Args) {
StringRef Arg = *ArgIt;
- if (Arg.startswith("--"))
+ if (Arg.starts_with("--"))
Arg = Arg.substr(2);
size_t len = Expected.size();
@@ -1297,7 +1297,7 @@ static const char *matchFlagWithArg(StringRef Expected,
return *ArgIt;
}
- if (Arg.startswith(Expected) && Arg.size() > len && Arg[len] == '=')
+ if (Arg.starts_with(Expected) && Arg.size() > len && Arg[len] == '=')
return Arg.data() + len + 1;
return nullptr;
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index ef1c50fc2284e..1c869e1739319 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -75,7 +75,7 @@ static void WriteOutputFile(const Module *M, const ModuleSummaryIndex *Index) {
OutputFilename = "-";
} else {
StringRef IFN = InputFilename;
- OutputFilename = (IFN.endswith(".ll") ? IFN.drop_back(3) : IFN).str();
+ OutputFilename = (IFN.ends_with(".ll") ? IFN.drop_back(3) : IFN).str();
OutputFilename += ".bc";
}
}
diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index e86eb2b44b105..f31098eb67cca 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -454,11 +454,11 @@ int main(int argc, char **argv) {
/// extension. Returns true if Lib is in a recognized format.
auto GetComponentLibraryNameSlice = [&](const StringRef &Lib,
StringRef &Out) {
- if (Lib.startswith("lib")) {
+ if (Lib.starts_with("lib")) {
unsigned FromEnd;
- if (Lib.endswith(StaticExt)) {
+ if (Lib.ends_with(StaticExt)) {
FromEnd = StaticExt.size() + 1;
- } else if (Lib.endswith(SharedExt)) {
+ } else if (Lib.ends_with(SharedExt)) {
FromEnd = SharedExt.size() + 1;
} else {
FromEnd = 0;
@@ -481,7 +481,7 @@ int main(int argc, char **argv) {
// Treat the DyLibName specially. It is not a component library and
// already has the necessary prefix and suffix (e.g. `.so`) added so
// just return it unmodified.
- assert(Lib.endswith(SharedExt) && "DyLib is missing suffix");
+ assert(Lib.ends_with(SharedExt) && "DyLib is missing suffix");
LibFileName = std::string(Lib);
} else {
LibFileName = (SharedPrefix + Lib + "." + SharedExt).str();
@@ -507,7 +507,7 @@ int main(int argc, char **argv) {
for (int i = 1; i != argc; ++i) {
StringRef Arg = argv[i];
- if (Arg.startswith("-")) {
+ if (Arg.starts_with("-")) {
HasAnyOption = true;
if (Arg == "--version") {
OS << PACKAGE_VERSION << '\n';
diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
index f35f62632763b..c04aec19174b8 100644
--- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
+++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
@@ -217,7 +217,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
// VFTables in the MS-ABI start with '??_7' and are contained within their
// own COMDAT section. We then determine the contents of the VFTable by
// looking at each relocation in the section.
- if (SymName.startswith("??_7")) {
+ if (SymName.starts_with("??_7")) {
// Each relocation either names a virtual method or a thunk. We note the
// offset into the section and the symbol used for the relocation.
collectRelocationOffsets(Obj, Sec, SecAddress, SecAddress, SecSize,
@@ -225,14 +225,14 @@ static void dumpCXXData(const ObjectFile *Obj) {
}
// VBTables in the MS-ABI start with '??_8' and are filled with 32-bit
// offsets of virtual bases.
- else if (SymName.startswith("??_8")) {
+ else if (SymName.starts_with("??_8")) {
ArrayRef<little32_t> VBTableData(
reinterpret_cast<const little32_t *>(SymContents.data()),
SymContents.size() / sizeof(little32_t));
VBTables[SymName] = VBTableData;
}
// Complete object locators in the MS-ABI start with '??_R4'
- else if (SymName.startswith("??_R4")) {
+ else if (SymName.starts_with("??_R4")) {
CompleteObjectLocator COL;
COL.Data =
ArrayRef(reinterpret_cast<const little32_t *>(SymContents.data()), 3);
@@ -241,7 +241,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
COLs[SymName] = COL;
}
// Class hierarchy descriptors in the MS-ABI start with '??_R3'
- else if (SymName.startswith("??_R3")) {
+ else if (SymName.starts_with("??_R3")) {
ClassHierarchyDescriptor CHD;
CHD.Data =
ArrayRef(reinterpret_cast<const little32_t *>(SymContents.data()), 3);
@@ -250,14 +250,14 @@ static void dumpCXXData(const ObjectFile *Obj) {
CHDs[SymName] = CHD;
}
// Class hierarchy descriptors in the MS-ABI start with '??_R2'
- else if (SymName.startswith("??_R2")) {
+ else if (SymName.starts_with("??_R2")) {
// Each relocation names a base class descriptor. We note the offset into
// the section and the symbol used for the relocation.
collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
SymName, BCAEntries);
}
// Base class descriptors in the MS-ABI start with '??_R1'
- else if (SymName.startswith("??_R1")) {
+ else if (SymName.starts_with("??_R1")) {
BaseClassDescriptor BCD;
BCD.Data = ArrayRef(
reinterpret_cast<const little32_t *>(SymContents.data()) + 1, 5);
@@ -266,7 +266,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
BCDs[SymName] = BCD;
}
// Type descriptors in the MS-ABI start with '??_R0'
- else if (SymName.startswith("??_R0")) {
+ else if (SymName.starts_with("??_R0")) {
const char *DataPtr = SymContents.drop_front(BytesInAddress).data();
TypeDescriptor TD;
if (BytesInAddress == 8)
@@ -279,7 +279,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
TDs[SymName] = TD;
}
// Throw descriptors in the MS-ABI start with '_TI'
- else if (SymName.startswith("_TI") || SymName.startswith("__TI")) {
+ else if (SymName.starts_with("_TI") || SymName.starts_with("__TI")) {
ThrowInfo TI;
TI.Flags = *reinterpret_cast<const little32_t *>(SymContents.data());
collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
@@ -287,7 +287,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
TIs[SymName] = TI;
}
// Catchable type arrays in the MS-ABI start with _CTA or __CTA.
- else if (SymName.startswith("_CTA") || SymName.startswith("__CTA")) {
+ else if (SymName.starts_with("_CTA") || SymName.starts_with("__CTA")) {
CatchableTypeArray CTA;
CTA.NumEntries =
*reinterpret_cast<const little32_t *>(SymContents.data());
@@ -296,7 +296,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
CTAs[SymName] = CTA;
}
// Catchable types in the MS-ABI start with _CT or __CT.
- else if (SymName.startswith("_CT") || SymName.startswith("__CT")) {
+ else if (SymName.starts_with("_CT") || SymName.starts_with("__CT")) {
const little32_t *DataPtr =
reinterpret_cast<const little32_t *>(SymContents.data());
CatchableType CT;
@@ -310,16 +310,16 @@ static void dumpCXXData(const ObjectFile *Obj) {
CTs[SymName] = CT;
}
// Construction vtables in the Itanium ABI start with '_ZTT' or '__ZTT'.
- else if (SymName.startswith("_ZTT") || SymName.startswith("__ZTT")) {
+ else if (SymName.starts_with("_ZTT") || SymName.starts_with("__ZTT")) {
collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
SymName, VTTEntries);
}
// Typeinfo names in the Itanium ABI start with '_ZTS' or '__ZTS'.
- else if (SymName.startswith("_ZTS") || SymName.startswith("__ZTS")) {
+ else if (SymName.starts_with("_ZTS") || SymName.starts_with("__ZTS")) {
TINames[SymName] = SymContents.slice(0, SymContents.find('\0'));
}
// Vtables in the Itanium ABI start with '_ZTV' or '__ZTV'.
- else if (SymName.startswith("_ZTV") || SymName.startswith("__ZTV")) {
+ else if (SymName.starts_with("_ZTV") || SymName.starts_with("__ZTV")) {
collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
SymName, VTableSymEntries);
for (uint64_t SymOffI = 0; SymOffI < SymSize; SymOffI += BytesInAddress) {
@@ -337,7 +337,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
}
}
// Typeinfo structures in the Itanium ABI start with '_ZTI' or '__ZTI'.
- else if (SymName.startswith("_ZTI") || SymName.startswith("__ZTI")) {
+ else if (SymName.starts_with("_ZTI") || SymName.starts_with("__ZTI")) {
// FIXME: Do something with these!
}
}
diff --git a/llvm/tools/llvm-diff/llvm-diff.cpp b/llvm/tools/llvm-diff/llvm-diff.cpp
index 7349469c80d6d..6fe18a51c9f55 100644
--- a/llvm/tools/llvm-diff/llvm-diff.cpp
+++ b/llvm/tools/llvm-diff/llvm-diff.cpp
@@ -42,7 +42,8 @@ static std::unique_ptr<Module> readModule(LLVMContext &Context,
static void diffGlobal(DifferenceEngine &Engine, Module &L, Module &R,
StringRef Name) {
// Drop leading sigils from the global name.
- if (Name.startswith("@")) Name = Name.substr(1);
+ if (Name.starts_with("@"))
+ Name = Name.substr(1);
Function *LFn = L.getFunction(Name);
Function *RFn = R.getFunction(Name);
diff --git a/llvm/tools/llvm-dis/llvm-dis.cpp b/llvm/tools/llvm-dis/llvm-dis.cpp
index 4996fc12ae32a..06fc669390bf1 100644
--- a/llvm/tools/llvm-dis/llvm-dis.cpp
+++ b/llvm/tools/llvm-dis/llvm-dis.cpp
@@ -225,7 +225,7 @@ int main(int argc, char **argv) {
FinalFilename = "-";
} else {
StringRef IFN = InputFilename;
- FinalFilename = (IFN.endswith(".bc") ? IFN.drop_back(3) : IFN).str();
+ FinalFilename = (IFN.ends_with(".bc") ? IFN.drop_back(3) : IFN).str();
if (N > 1)
FinalFilename += std::string(".") + std::to_string(I);
FinalFilename += ".ll";
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h
index d9d99ffc8747d..77cb8bb1aa7dd 100644
--- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h
+++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h
@@ -18,7 +18,7 @@ namespace llvm {
namespace dwarfutil {
inline bool isDebugSection(StringRef SecName) {
- return SecName.startswith(".debug") || SecName.startswith(".zdebug") ||
+ return SecName.starts_with(".debug") || SecName.starts_with(".zdebug") ||
SecName == ".gdb_index";
}
diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
index d025fe955be51..f1904ea159bf1 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -210,9 +210,9 @@ static const char *isInvalidOpcode(const Instruction &Instr) {
const auto OpcodeName = Instr.Name;
if ((Instr.Description.TSFlags & X86II::FormMask) == X86II::Pseudo)
return "unsupported opcode: pseudo instruction";
- if ((OpcodeName.startswith("POP") && !OpcodeName.startswith("POPCNT")) ||
- OpcodeName.startswith("PUSH") || OpcodeName.startswith("ADJCALLSTACK") ||
- OpcodeName.startswith("LEAVE"))
+ if ((OpcodeName.starts_with("POP") && !OpcodeName.starts_with("POPCNT")) ||
+ OpcodeName.starts_with("PUSH") || OpcodeName.starts_with("ADJCALLSTACK") ||
+ OpcodeName.starts_with("LEAVE"))
return "unsupported opcode: Push/Pop/AdjCallStack/Leave";
switch (Instr.Description.Opcode) {
case X86::LFS16rm:
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 3d6247ca6a25f..aa032c97485fb 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1547,8 +1547,8 @@ static Error addObjects(Session &S,
unsigned InputFileArgIdx =
InputFiles.getPosition(InputFileItr - InputFiles.begin());
const std::string &InputFile = *InputFileItr;
- if (StringRef(InputFile).endswith(".a") ||
- StringRef(InputFile).endswith(".lib"))
+ if (StringRef(InputFile).ends_with(".a") ||
+ StringRef(InputFile).ends_with(".lib"))
continue;
auto &JD = *std::prev(IdxToJD.lower_bound(InputFileArgIdx))->second;
LLVM_DEBUG(dbgs() << " " << InputFileArgIdx << ": \"" << InputFile
@@ -1648,7 +1648,7 @@ static Error addLibraries(Session &S,
for (auto InputFileItr = InputFiles.begin(), InputFileEnd = InputFiles.end();
InputFileItr != InputFileEnd; ++InputFileItr) {
StringRef InputFile = *InputFileItr;
- if (!InputFile.endswith(".a") && !InputFile.endswith(".lib"))
+ if (!InputFile.ends_with(".a") && !InputFile.ends_with(".lib"))
continue;
LibraryLoad LL;
LL.LibName = InputFile.str();
diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
index 9680cfa13cc5c..45e04d8f9dd04 100644
--- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -132,7 +132,7 @@ static Expected<std::string> searchForFile(const Twine &FileName) {
static Error processCommandLineLibraries() {
for (StringRef BaseName : Libraries) {
Expected<std::string> FullPath = searchForFile(
- BaseName.endswith(".o") ? BaseName.str() : "lib" + BaseName + ".a");
+ BaseName.ends_with(".o") ? BaseName.str() : "lib" + BaseName + ".a");
if (!FullPath)
return FullPath.takeError();
InputFiles.push_back(FullPath.get());
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index fede89e9c1167..19ee5374979c8 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -900,7 +900,7 @@ static char getSymbolNMTypeChar(ELFObjectFileBase &Obj,
consumeError(NameOrErr.takeError());
return '?';
}
- if ((*NameOrErr).startswith(".debug"))
+ if ((*NameOrErr).starts_with(".debug"))
return 'N';
if (!(Flags & ELF::SHF_WRITE))
return 'n';
@@ -939,7 +939,7 @@ static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
const coff_section *Section = Obj.getCOFFSection(*SecI);
Characteristics = Section->Characteristics;
if (Expected<StringRef> NameOrErr = Obj.getSectionName(Section))
- if (NameOrErr->startswith(".idata"))
+ if (NameOrErr->starts_with(".idata"))
return 'i';
}
@@ -1738,13 +1738,13 @@ static void getXCOFFExports(XCOFFObjectFile *XCOFFObj,
StringRef SymName = cantFail(Sym.getName());
if (SymName.empty())
continue;
- if (SymName.startswith("__sinit") || SymName.startswith("__sterm") ||
+ if (SymName.starts_with("__sinit") || SymName.starts_with("__sterm") ||
SymName.front() == '.' || SymName.front() == '(')
continue;
// Check the SymName regex matching with "^__[0-9]+__".
- if (SymName.size() > 4 && SymName.startswith("__") &&
- SymName.endswith("__")) {
+ if (SymName.size() > 4 && SymName.starts_with("__") &&
+ SymName.ends_with("__")) {
if (std::all_of(SymName.begin() + 2, SymName.end() - 2, isDigit))
continue;
}
@@ -1752,9 +1752,9 @@ static void getXCOFFExports(XCOFFObjectFile *XCOFFObj,
if (SymName == "__rsrc" && NoRsrc)
continue;
- if (SymName.startswith("__tf1"))
+ if (SymName.starts_with("__tf1"))
SymName = SymName.substr(6);
- else if (SymName.startswith("__tf9"))
+ else if (SymName.starts_with("__tf9"))
SymName = SymName.substr(14);
NMSymbol S = {};
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index 5712902539443..efc09f308f46f 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -315,7 +315,7 @@ getOutputTargetInfoByTargetName(StringRef TargetName) {
MI.OSABI = ELF::ELFOSABI_FREEBSD;
FileFormat Format;
- if (TargetName.startswith("elf"))
+ if (TargetName.starts_with("elf"))
Format = FileFormat::ELF;
else
// This should never happen because `TargetName` is valid (it certainly
diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp
index 8f685a21505c1..71697fa01e627 100644
--- a/llvm/tools/llvm-objdump/COFFDump.cpp
+++ b/llvm/tools/llvm-objdump/COFFDump.cpp
@@ -857,7 +857,7 @@ void objdump::printCOFFSymbolTable(const COFFObjectFile &coff) {
<< "(nx " << unsigned(Symbol->getNumberOfAuxSymbols()) << ") "
<< "0x" << format("%08x", unsigned(Symbol->getValue())) << " "
<< Name;
- if (Demangle && Name.startswith("?")) {
+ if (Demangle && Name.starts_with("?")) {
int Status = -1;
char *DemangledSymbol = microsoftDemangle(Name, nullptr, &Status);
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index f80a12d2f84b8..0e6935c0ac589 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -290,7 +290,7 @@ static void getSectionsAndSymbols(MachOObjectFile *MachOObj,
const StringRef FileName = MachOObj->getFileName();
for (const SymbolRef &Symbol : MachOObj->symbols()) {
StringRef SymName = unwrapOrError(Symbol.getName(), FileName);
- if (!SymName.startswith("ltmp"))
+ if (!SymName.starts_with("ltmp"))
Symbols.push_back(Symbol);
}
@@ -1482,7 +1482,7 @@ static void CreateSymbolAddressMap(MachOObjectFile *O,
ST == SymbolRef::ST_Other) {
uint64_t Address = cantFail(Symbol.getValue());
StringRef SymName = unwrapOrError(Symbol.getName(), FileName);
- if (!SymName.startswith(".objc"))
+ if (!SymName.starts_with(".objc"))
(*AddrMap)[Address] = SymName;
}
}
diff --git a/llvm/tools/llvm-objdump/SourcePrinter.cpp b/llvm/tools/llvm-objdump/SourcePrinter.cpp
index b2fe56cf2e1cc..76da86587586e 100644
--- a/llvm/tools/llvm-objdump/SourcePrinter.cpp
+++ b/llvm/tools/llvm-objdump/SourcePrinter.cpp
@@ -436,7 +436,7 @@ void SourcePrinter::printLines(formatted_raw_ostream &OS,
OS << Delimiter << LineInfo.FunctionName;
// If demangling is successful, FunctionName will end with "()". Print it
// only if demangling did not run or was unsuccessful.
- if (!StringRef(LineInfo.FunctionName).endswith("()"))
+ if (!StringRef(LineInfo.FunctionName).ends_with("()"))
OS << "()";
OS << ":\n";
}
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 631ca955776d4..12bb70d5537d8 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1538,7 +1538,7 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
// __mh_(execute|dylib|dylinker|bundle|preload|object)_header are special
// symbols that support MachO header introspection. They do not bind to
// code locations and are irrelevant for disassembly.
- if (NameOrErr->startswith("__mh_") && NameOrErr->endswith("_header"))
+ if (NameOrErr->starts_with("__mh_") && NameOrErr->ends_with("_header"))
continue;
// Don't ask a Mach-O STAB symbol for its section unless you know that
// STAB symbol's section field refers to a valid section index. Otherwise
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 63e34d81f1892..088138f27de58 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -1514,7 +1514,7 @@ static void parseInputFilenamesFile(MemoryBuffer *Buffer,
for (const StringRef &FileWeightEntry : Entries) {
StringRef SanitizedEntry = FileWeightEntry.trim(" \t\v\f\r");
// Skip comments.
- if (SanitizedEntry.startswith("#"))
+ if (SanitizedEntry.starts_with("#"))
continue;
// If there's no comma, it's an unweighted profile.
else if (!SanitizedEntry.contains(','))
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index 9f45167306904..313d40483a259 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -597,7 +597,7 @@ bool PerfScriptReader::extractCallstack(TraceStream &TraceIt,
// It's in bottom-up order with each frame in one line.
// Extract stack frames from sample
- while (!TraceIt.isAtEoF() && !TraceIt.getCurrentLine().startswith(" 0x")) {
+ while (!TraceIt.isAtEoF() && !TraceIt.getCurrentLine().starts_with(" 0x")) {
StringRef FrameStr = TraceIt.getCurrentLine().ltrim();
uint64_t FrameAddr = 0;
if (FrameStr.getAsInteger(16, FrameAddr)) {
@@ -645,7 +645,7 @@ bool PerfScriptReader::extractCallstack(TraceStream &TraceIt,
// Skip other unrelated line, find the next valid LBR line
// Note that even for empty call stack, we should skip the address at the
// bottom, otherwise the following pass may generate a truncated callstack
- while (!TraceIt.isAtEoF() && !TraceIt.getCurrentLine().startswith(" 0x")) {
+ while (!TraceIt.isAtEoF() && !TraceIt.getCurrentLine().starts_with(" 0x")) {
TraceIt.advance();
}
// Filter out broken stack sample. We may not have complete frame info
@@ -690,14 +690,14 @@ void HybridPerfReader::parseSample(TraceStream &TraceIt, uint64_t Count) {
// Parsing call stack and populate into PerfSample.CallStack
if (!extractCallstack(TraceIt, Sample->CallStack)) {
// Skip the next LBR line matched current call stack
- if (!TraceIt.isAtEoF() && TraceIt.getCurrentLine().startswith(" 0x"))
+ if (!TraceIt.isAtEoF() && TraceIt.getCurrentLine().starts_with(" 0x"))
TraceIt.advance();
return;
}
warnIfMissingMMap();
- if (!TraceIt.isAtEoF() && TraceIt.getCurrentLine().startswith(" 0x")) {
+ if (!TraceIt.isAtEoF() && TraceIt.getCurrentLine().starts_with(" 0x")) {
// Parsing LBR stack and populate into PerfSample.LBRStack
if (extractLBRStack(TraceIt, Sample->LBRStack)) {
if (IgnoreStackSamples) {
@@ -846,7 +846,7 @@ void UnsymbolizedProfileReader::readUnsymbolizedProfile(StringRef FileName) {
std::make_shared<StringBasedCtxKey>();
StringRef Line = TraceIt.getCurrentLine();
// Read context stack for CS profile.
- if (Line.startswith("[")) {
+ if (Line.starts_with("[")) {
ProfileIsCS = true;
auto I = ContextStrSet.insert(Line.str());
SampleContext::createCtxVectorFromStr(*I.first, Key->Context);
@@ -1005,7 +1005,7 @@ bool PerfScriptReader::isLBRSample(StringRef Line) {
Line.trim().split(Records, " ", 2, false);
if (Records.size() < 2)
return false;
- if (Records[1].startswith("0x") && Records[1].contains('/'))
+ if (Records[1].starts_with("0x") && Records[1].contains('/'))
return true;
return false;
}
diff --git a/llvm/tools/llvm-rc/ResourceScriptCppFilter.cpp b/llvm/tools/llvm-rc/ResourceScriptCppFilter.cpp
index 6657aa54cf6e7..3081dbbb6d765 100644
--- a/llvm/tools/llvm-rc/ResourceScriptCppFilter.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptCppFilter.cpp
@@ -67,7 +67,7 @@ bool Filter::parseLine(StringRef Line) {
// false since the preprocessing directives should be filtered out.
Line.consume_front("line");
- if (!Line.startswith(" "))
+ if (!Line.starts_with(" "))
return false; // Not a line directive (pragma etc).
// #line 123 "path/file.h"
diff --git a/llvm/tools/llvm-rc/ResourceScriptToken.cpp b/llvm/tools/llvm-rc/ResourceScriptToken.cpp
index a8f40abdf8a68..aad1060c4a381 100644
--- a/llvm/tools/llvm-rc/ResourceScriptToken.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptToken.cpp
@@ -274,7 +274,7 @@ Error Tokenizer::consumeToken(const Kind TokenKind) {
}
bool Tokenizer::willNowRead(StringRef FollowingChars) const {
- return Data.drop_front(Pos).startswith(FollowingChars);
+ return Data.drop_front(Pos).starts_with(FollowingChars);
}
bool Tokenizer::canStartIdentifier() const {
@@ -298,12 +298,12 @@ bool Tokenizer::canStartInt() const {
bool Tokenizer::canStartBlockComment() const {
assert(!streamEof());
- return Data.drop_front(Pos).startswith("/*");
+ return Data.drop_front(Pos).starts_with("/*");
}
bool Tokenizer::canStartLineComment() const {
assert(!streamEof());
- return Data.drop_front(Pos).startswith("//");
+ return Data.drop_front(Pos).starts_with("//");
}
bool Tokenizer::canContinueInt() const {
diff --git a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
index cf5c77cf107c3..b77839c2c57c1 100644
--- a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
+++ b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
@@ -1476,7 +1476,7 @@ Error Decoder::dumpProcedureData(const COFFObjectFile &COFF) {
if (!NameOrErr)
return NameOrErr.takeError();
- if (NameOrErr->startswith(".pdata"))
+ if (NameOrErr->starts_with(".pdata"))
dumpProcedureData(COFF, Section);
}
return Error::success();
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 3ad40dc355108..32b1d6a2089ca 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -1946,7 +1946,7 @@ void COFFDumper::printCOFFResources() {
ListScope ResourcesD(W, "Resources");
for (const SectionRef &S : Obj->sections()) {
StringRef Name = unwrapOrError(Obj->getFileName(), S.getName());
- if (!Name.startswith(".rsrc"))
+ if (!Name.starts_with(".rsrc"))
continue;
StringRef Ref = unwrapOrError(Obj->getFileName(), S.getContents());
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 85d5ab68b495c..9e917139b4747 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1500,7 +1500,7 @@ static std::string getGNUPtType(unsigned Arch, unsigned Type) {
return Seg.str();
// E.g. "PT_LOAD" -> "LOAD".
- assert(Seg.startswith("PT_"));
+ assert(Seg.starts_with("PT_"));
return Seg.drop_front(3).str();
}
@@ -5862,13 +5862,13 @@ StringRef getNoteTypeName(const typename ELFT::Note &Note, unsigned ELFType) {
return FindNote(FreeBSDNoteTypes);
}
}
- if (ELFType == ELF::ET_CORE && Name.startswith("NetBSD-CORE")) {
+ if (ELFType == ELF::ET_CORE && Name.starts_with("NetBSD-CORE")) {
StringRef Result = FindNote(NetBSDCoreNoteTypes);
if (!Result.empty())
return Result;
return FindNote(CoreNoteTypes);
}
- if (ELFType == ELF::ET_CORE && Name.startswith("OpenBSD")) {
+ if (ELFType == ELF::ET_CORE && Name.starts_with("OpenBSD")) {
// OpenBSD also places the generic core notes in the OpenBSD namespace.
StringRef Result = FindNote(OpenBSDCoreNoteTypes);
if (!Result.empty())
diff --git a/llvm/tools/llvm-readobj/Win64EHDumper.cpp b/llvm/tools/llvm-readobj/Win64EHDumper.cpp
index 2896f20336c52..e4bd772191514 100644
--- a/llvm/tools/llvm-readobj/Win64EHDumper.cpp
+++ b/llvm/tools/llvm-readobj/Win64EHDumper.cpp
@@ -397,7 +397,7 @@ void Dumper::printData(const Context &Ctx) {
else
consumeError(NameOrErr.takeError());
- if (Name != ".pdata" && !Name.startswith(".pdata$"))
+ if (Name != ".pdata" && !Name.starts_with(".pdata$"))
continue;
const coff_section *PData = Ctx.COFF.getCOFFSection(Section);
diff --git a/llvm/tools/llvm-reduce/deltas/StripDebugInfo.cpp b/llvm/tools/llvm-reduce/deltas/StripDebugInfo.cpp
index a65e55d5f6f48..c9e1261c366a7 100644
--- a/llvm/tools/llvm-reduce/deltas/StripDebugInfo.cpp
+++ b/llvm/tools/llvm-reduce/deltas/StripDebugInfo.cpp
@@ -18,7 +18,7 @@ using namespace llvm;
static void stripDebugInfoImpl(Oracle &O, ReducerWorkItem &WorkItem) {
Module &Program = WorkItem.getModule();
bool HasDebugInfo = any_of(Program.named_metadata(), [](NamedMDNode &NMD) {
- return NMD.getName().startswith("llvm.dbg.");
+ return NMD.getName().starts_with("llvm.dbg.");
});
if (HasDebugInfo && !O.shouldKeep())
StripDebugInfo(Program);
diff --git a/llvm/tools/llvm-reduce/llvm-reduce.cpp b/llvm/tools/llvm-reduce/llvm-reduce.cpp
index 466efe4bd4396..bd2db635b4d8d 100644
--- a/llvm/tools/llvm-reduce/llvm-reduce.cpp
+++ b/llvm/tools/llvm-reduce/llvm-reduce.cpp
@@ -157,7 +157,7 @@ int main(int Argc, char **Argv) {
if (InputLanguage != InputLanguages::None) {
if (InputLanguage == InputLanguages::MIR)
ReduceModeMIR = true;
- } else if (StringRef(InputFilename).endswith(".mir")) {
+ } else if (StringRef(InputFilename).ends_with(".mir")) {
ReduceModeMIR = true;
}
diff --git a/llvm/tools/llvm-stress/llvm-stress.cpp b/llvm/tools/llvm-stress/llvm-stress.cpp
index 783316d676550..8cb7fce5c366b 100644
--- a/llvm/tools/llvm-stress/llvm-stress.cpp
+++ b/llvm/tools/llvm-stress/llvm-stress.cpp
@@ -175,7 +175,7 @@ struct Modifier {
Ty = Type::getPPC_FP128Ty(Context);
else if (Arg == "x86_mmx")
Ty = Type::getX86_MMXTy(Context);
- else if (Arg.startswith("i")) {
+ else if (Arg.starts_with("i")) {
unsigned N = 0;
Arg.drop_front().getAsInteger(10, N);
if (N > 0)
diff --git a/llvm/tools/llvm-undname/llvm-undname.cpp b/llvm/tools/llvm-undname/llvm-undname.cpp
index 96f031abe9c1f..d2d76def7ae0f 100644
--- a/llvm/tools/llvm-undname/llvm-undname.cpp
+++ b/llvm/tools/llvm-undname/llvm-undname.cpp
@@ -116,7 +116,7 @@ int main(int argc, char **argv) {
StringRef Line(LineStr);
Line = Line.trim();
- if (Line.empty() || Line.startswith("#") || Line.startswith(";"))
+ if (Line.empty() || Line.starts_with("#") || Line.starts_with(";"))
continue;
// If the user is manually typing in these decorated names, don't echo
diff --git a/llvm/tools/obj2yaml/archive2yaml.cpp b/llvm/tools/obj2yaml/archive2yaml.cpp
index c7b0ee4802930..35bcd434c8fa3 100644
--- a/llvm/tools/obj2yaml/archive2yaml.cpp
+++ b/llvm/tools/obj2yaml/archive2yaml.cpp
@@ -24,7 +24,7 @@ class ArchiveDumper {
std::make_unique<ArchYAML::Archive>();
StringRef Magic = "!<arch>\n";
- if (!Buffer.startswith(Magic))
+ if (!Buffer.starts_with(Magic))
return createStringError(std::errc::not_supported,
"only regular archives are supported");
Obj->Magic = Magic;
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index bec4a10a5d35f..86bd138c22064 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -514,7 +514,7 @@ std::optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections(
std::vector<std::unique_ptr<ELFYAML::Chunk>> &Sections) {
DWARFYAML::Data DWARF;
for (std::unique_ptr<ELFYAML::Chunk> &C : Sections) {
- if (!C->Name.startswith(".debug_"))
+ if (!C->Name.starts_with(".debug_"))
continue;
if (ELFYAML::RawContentSection *RawSec =
diff --git a/llvm/tools/obj2yaml/macho2yaml.cpp b/llvm/tools/obj2yaml/macho2yaml.cpp
index efd43a5f1285f..c006c0d2cbea4 100644
--- a/llvm/tools/obj2yaml/macho2yaml.cpp
+++ b/llvm/tools/obj2yaml/macho2yaml.cpp
@@ -151,7 +151,7 @@ static Error dumpDebugSection(StringRef SecName, DWARFContext &DCtx,
dumpDebugLines(DCtx, DWARF);
return Error::success();
}
- if (SecName.startswith("__debug_pub")) {
+ if (SecName.starts_with("__debug_pub")) {
// FIXME: We should extract pub-section dumpers from this function.
dumpDebugPubSections(DCtx, DWARF);
return Error::success();
@@ -183,11 +183,11 @@ Expected<const char *> MachODumper::extractSections(
// Copy data sections if requested.
if ((RawSegment & ::RawSegments::data) &&
- StringRef(S->segname).startswith("__DATA"))
+ StringRef(S->segname).starts_with("__DATA"))
S->content =
yaml::BinaryRef(Obj.getSectionContents(Sec.offset, Sec.size));
- if (SecName.startswith("__debug_")) {
+ if (SecName.starts_with("__debug_")) {
// If the DWARF section cannot be successfully parsed, emit raw content
// instead of an entry in the DWARF section of the YAML.
if (Error Err = dumpDebugSection(SecName, *DWARFCtx, Y.DWARF))
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index c450c02a05ec4..8557a38405193 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -205,7 +205,7 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
std::unique_ptr<WasmYAML::Section> S;
switch (WasmSec.Type) {
case wasm::WASM_SEC_CUSTOM: {
- if (WasmSec.Name.startswith("reloc.")) {
+ if (WasmSec.Name.starts_with("reloc.")) {
// Relocations are attached the sections they apply to rather than
// being represented as a custom section in the YAML output.
continue;
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 5e5e5ce233f31..221c6a5b1adcc 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -376,7 +376,7 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
"callbrprepare",
};
for (const auto &P : PassNamePrefix)
- if (Pass.startswith(P))
+ if (Pass.starts_with(P))
return true;
for (const auto &P : PassNameContain)
if (Pass.contains(P))
diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp
index ba1f54d2ecf7c..b7f5356e22a9e 100644
--- a/llvm/tools/yaml2obj/yaml2obj.cpp
+++ b/llvm/tools/yaml2obj/yaml2obj.cpp
@@ -78,9 +78,9 @@ static std::optional<std::string> preprocess(StringRef Buf,
std::string Preprocessed;
while (!Buf.empty()) {
- if (Buf.startswith("[[")) {
+ if (Buf.starts_with("[[")) {
size_t I = Buf.find_first_of("[]", 2);
- if (Buf.substr(I).startswith("]]")) {
+ if (Buf.substr(I).starts_with("]]")) {
StringRef MacroExpr = Buf.substr(2, I - 2);
StringRef Macro;
StringRef Default;
@@ -92,7 +92,7 @@ static std::optional<std::string> preprocess(StringRef Buf,
std::optional<StringRef> Value;
if (It != Defines.end())
Value = It->second;
- else if (!Default.empty() || MacroExpr.endswith("="))
+ else if (!Default.empty() || MacroExpr.ends_with("="))
Value = Default;
if (Value) {
diff --git a/llvm/utils/split-file/split-file.cpp b/llvm/utils/split-file/split-file.cpp
index 4a92c1be78a2b..2ad04d6e42f2b 100644
--- a/llvm/utils/split-file/split-file.cpp
+++ b/llvm/utils/split-file/split-file.cpp
@@ -75,9 +75,9 @@ static int handle(MemoryBuffer &inputBuf, StringRef input) {
for (line_iterator i(inputBuf, /*SkipBlanks=*/false, '\0'); !i.is_at_eof();) {
const int64_t lineNo = i.line_number();
const StringRef line = *i++;
- const size_t markerLen = line.startswith("//") ? 6 : 5;
+ const size_t markerLen = line.starts_with("//") ? 6 : 5;
if (!(line.size() >= markerLen &&
- line.substr(markerLen - 4).startswith("--- ")))
+ line.substr(markerLen - 4).starts_with("--- ")))
continue;
separator = line.substr(0, markerLen);
const StringRef partName = line.substr(markerLen);
diff --git a/llvm/utils/yaml-bench/YAMLBench.cpp b/llvm/utils/yaml-bench/YAMLBench.cpp
index 8b4043ef66cbf..50e55538a011c 100644
--- a/llvm/utils/yaml-bench/YAMLBench.cpp
+++ b/llvm/utils/yaml-bench/YAMLBench.cpp
@@ -70,7 +70,7 @@ static raw_ostream &operator <<(raw_ostream &os, const indent &in) {
/// Pretty print a tag by replacing tag:yaml.org,2002: with !!.
static std::string prettyTag(yaml::Node *N) {
std::string Tag = N->getVerbatimTag();
- if (StringRef(Tag).startswith("tag:yaml.org,2002:")) {
+ if (StringRef(Tag).starts_with("tag:yaml.org,2002:")) {
std::string Ret = "!!";
Ret += StringRef(Tag).substr(18);
return Ret;
>From ffccee1ea3076fec801ca5c350d17fc3a6098d20 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 11 Dec 2023 08:03:06 -0800
Subject: [PATCH 2/2] clang-format
---
llvm/lib/CodeGen/GlobalMerge.cpp | 3 +-
.../CodeGen/TargetLoweringObjectFileImpl.cpp | 15 +--
llvm/lib/Option/ArgList.cpp | 4 +-
.../lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 127 ++++++++----------
llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp | 12 +-
.../lib/Target/X86/AsmParser/X86AsmParser.cpp | 1 -
llvm/tools/llvm-exegesis/lib/X86/Target.cpp | 4 +-
7 files changed, 76 insertions(+), 90 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index ab4b26e294106..22b6d31d06349 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -643,8 +643,7 @@ bool GlobalMerge::doInitialization(Module &M) {
StringRef Section = GV.getSection();
// Ignore all 'special' globals.
- if (GV.getName().starts_with("llvm.") ||
- GV.getName().starts_with(".llvm."))
+ if (GV.getName().starts_with("llvm.") || GV.getName().starts_with(".llvm."))
continue;
// Ignore all "required" globals:
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index c71ba4d71efaf..27d47aab4b683 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -478,24 +478,19 @@ 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.starts_with(".bss.") ||
+ 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.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.starts_with(".tdata.") ||
+ 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.starts_with(".tbss.") ||
+ if (Name == ".tbss" || Name.starts_with(".tbss.") ||
Name.starts_with(".gnu.linkonce.tb.") ||
Name.starts_with(".llvm.linkonce.tb."))
return SectionKind::getThreadBSS();
diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp
index 9fcc91a9278db..72003e3a52591 100644
--- a/llvm/lib/Option/ArgList.cpp
+++ b/llvm/lib/Option/ArgList.cpp
@@ -185,8 +185,8 @@ const char *ArgList::GetOrMakeJoinedArgString(unsigned Index,
StringRef LHS,
StringRef RHS) const {
StringRef Cur = getArgString(Index);
- if (Cur.size() == LHS.size() + RHS.size() &&
- Cur.starts_with(LHS) && Cur.ends_with(RHS))
+ if (Cur.size() == LHS.size() + RHS.size() && Cur.starts_with(LHS) &&
+ Cur.ends_with(RHS))
return Cur.data();
return MakeArgString(LHS + RHS);
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 7405e370e0487..18dccb26b8776 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -6295,32 +6295,29 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
// Ignore some mnemonics we know aren't predicated forms.
//
// FIXME: Would be nice to autogen this.
- if ((Mnemonic == "movs" && isThumb()) ||
- Mnemonic == "teq" || Mnemonic == "vceq" || Mnemonic == "svc" ||
- Mnemonic == "mls" || Mnemonic == "smmls" || Mnemonic == "vcls" ||
- Mnemonic == "vmls" || Mnemonic == "vnmls" || Mnemonic == "vacge" ||
- Mnemonic == "vcge" || Mnemonic == "vclt" || Mnemonic == "vacgt" ||
- Mnemonic == "vaclt" || Mnemonic == "vacle" || Mnemonic == "hlt" ||
- Mnemonic == "vcgt" || Mnemonic == "vcle" || Mnemonic == "smlal" ||
- Mnemonic == "umaal" || Mnemonic == "umlal" || Mnemonic == "vabal" ||
- Mnemonic == "vmlal" || Mnemonic == "vpadal" || Mnemonic == "vqdmlal" ||
- Mnemonic == "fmuls" || Mnemonic == "vmaxnm" || Mnemonic == "vminnm" ||
- Mnemonic == "vcvta" || Mnemonic == "vcvtn" || Mnemonic == "vcvtp" ||
- Mnemonic == "vcvtm" || Mnemonic == "vrinta" || Mnemonic == "vrintn" ||
- Mnemonic == "vrintp" || Mnemonic == "vrintm" || Mnemonic == "hvc" ||
- Mnemonic.starts_with("vsel") || Mnemonic == "vins" || Mnemonic == "vmovx" ||
- Mnemonic == "bxns" || Mnemonic == "blxns" ||
- Mnemonic == "vdot" || Mnemonic == "vmmla" ||
- Mnemonic == "vudot" || Mnemonic == "vsdot" ||
- Mnemonic == "vcmla" || Mnemonic == "vcadd" ||
- Mnemonic == "vfmal" || Mnemonic == "vfmsl" ||
- Mnemonic == "wls" || Mnemonic == "le" || Mnemonic == "dls" ||
- Mnemonic == "csel" || Mnemonic == "csinc" ||
- Mnemonic == "csinv" || Mnemonic == "csneg" || Mnemonic == "cinc" ||
- Mnemonic == "cinv" || Mnemonic == "cneg" || Mnemonic == "cset" ||
- Mnemonic == "csetm" ||
- Mnemonic == "aut" || Mnemonic == "pac" || Mnemonic == "pacbti" ||
- Mnemonic == "bti")
+ if ((Mnemonic == "movs" && isThumb()) || Mnemonic == "teq" ||
+ Mnemonic == "vceq" || Mnemonic == "svc" || Mnemonic == "mls" ||
+ Mnemonic == "smmls" || Mnemonic == "vcls" || Mnemonic == "vmls" ||
+ Mnemonic == "vnmls" || Mnemonic == "vacge" || Mnemonic == "vcge" ||
+ Mnemonic == "vclt" || Mnemonic == "vacgt" || Mnemonic == "vaclt" ||
+ Mnemonic == "vacle" || Mnemonic == "hlt" || Mnemonic == "vcgt" ||
+ Mnemonic == "vcle" || Mnemonic == "smlal" || Mnemonic == "umaal" ||
+ Mnemonic == "umlal" || Mnemonic == "vabal" || Mnemonic == "vmlal" ||
+ Mnemonic == "vpadal" || Mnemonic == "vqdmlal" || Mnemonic == "fmuls" ||
+ Mnemonic == "vmaxnm" || Mnemonic == "vminnm" || Mnemonic == "vcvta" ||
+ Mnemonic == "vcvtn" || Mnemonic == "vcvtp" || Mnemonic == "vcvtm" ||
+ Mnemonic == "vrinta" || Mnemonic == "vrintn" || Mnemonic == "vrintp" ||
+ Mnemonic == "vrintm" || Mnemonic == "hvc" ||
+ Mnemonic.starts_with("vsel") || Mnemonic == "vins" ||
+ Mnemonic == "vmovx" || Mnemonic == "bxns" || Mnemonic == "blxns" ||
+ Mnemonic == "vdot" || Mnemonic == "vmmla" || Mnemonic == "vudot" ||
+ Mnemonic == "vsdot" || Mnemonic == "vcmla" || Mnemonic == "vcadd" ||
+ Mnemonic == "vfmal" || Mnemonic == "vfmsl" || Mnemonic == "wls" ||
+ Mnemonic == "le" || Mnemonic == "dls" || Mnemonic == "csel" ||
+ Mnemonic == "csinc" || Mnemonic == "csinv" || Mnemonic == "csneg" ||
+ Mnemonic == "cinc" || Mnemonic == "cinv" || Mnemonic == "cneg" ||
+ Mnemonic == "cset" || Mnemonic == "csetm" || Mnemonic == "aut" ||
+ Mnemonic == "pac" || Mnemonic == "pacbti" || Mnemonic == "bti")
return Mnemonic;
// First, split out any predication code. Ignore mnemonics we know aren't
@@ -6330,15 +6327,12 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
Mnemonic != "umlals" && Mnemonic != "umulls" && Mnemonic != "lsls" &&
Mnemonic != "sbcs" && Mnemonic != "rscs" &&
!(hasMVE() &&
- (Mnemonic == "vmine" ||
- Mnemonic == "vshle" || Mnemonic == "vshlt" || Mnemonic == "vshllt" ||
- Mnemonic == "vrshle" || Mnemonic == "vrshlt" ||
- Mnemonic == "vmvne" || Mnemonic == "vorne" ||
- Mnemonic == "vnege" || Mnemonic == "vnegt" ||
- Mnemonic == "vmule" || Mnemonic == "vmult" ||
- Mnemonic == "vrintne" ||
- Mnemonic == "vcmult" || Mnemonic == "vcmule" ||
- Mnemonic == "vpsele" || Mnemonic == "vpselt" ||
+ (Mnemonic == "vmine" || Mnemonic == "vshle" || Mnemonic == "vshlt" ||
+ Mnemonic == "vshllt" || Mnemonic == "vrshle" || Mnemonic == "vrshlt" ||
+ Mnemonic == "vmvne" || Mnemonic == "vorne" || Mnemonic == "vnege" ||
+ Mnemonic == "vnegt" || Mnemonic == "vmule" || Mnemonic == "vmult" ||
+ Mnemonic == "vrintne" || Mnemonic == "vcmult" ||
+ Mnemonic == "vcmule" || Mnemonic == "vpsele" || Mnemonic == "vpselt" ||
Mnemonic.starts_with("vq")))) {
unsigned CC = ARMCondCodeFromString(Mnemonic.substr(Mnemonic.size()-2));
if (CC != ~0U) {
@@ -6350,17 +6344,16 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
// Next, determine if we have a carry setting bit. We explicitly ignore all
// the instructions we know end in 's'.
if (Mnemonic.ends_with("s") &&
- !(Mnemonic == "cps" || Mnemonic == "mls" ||
- Mnemonic == "mrs" || Mnemonic == "smmls" || Mnemonic == "vabs" ||
- Mnemonic == "vcls" || Mnemonic == "vmls" || Mnemonic == "vmrs" ||
- Mnemonic == "vnmls" || Mnemonic == "vqabs" || Mnemonic == "vrecps" ||
- Mnemonic == "vrsqrts" || Mnemonic == "srs" || Mnemonic == "flds" ||
- Mnemonic == "fmrs" || Mnemonic == "fsqrts" || Mnemonic == "fsubs" ||
- Mnemonic == "fsts" || Mnemonic == "fcpys" || Mnemonic == "fdivs" ||
- Mnemonic == "fmuls" || Mnemonic == "fcmps" || Mnemonic == "fcmpzs" ||
- Mnemonic == "vfms" || Mnemonic == "vfnms" || Mnemonic == "fconsts" ||
- Mnemonic == "bxns" || Mnemonic == "blxns" || Mnemonic == "vfmas" ||
- Mnemonic == "vmlas" ||
+ !(Mnemonic == "cps" || Mnemonic == "mls" || Mnemonic == "mrs" ||
+ Mnemonic == "smmls" || Mnemonic == "vabs" || Mnemonic == "vcls" ||
+ Mnemonic == "vmls" || Mnemonic == "vmrs" || Mnemonic == "vnmls" ||
+ Mnemonic == "vqabs" || Mnemonic == "vrecps" || Mnemonic == "vrsqrts" ||
+ Mnemonic == "srs" || Mnemonic == "flds" || Mnemonic == "fmrs" ||
+ Mnemonic == "fsqrts" || Mnemonic == "fsubs" || Mnemonic == "fsts" ||
+ Mnemonic == "fcpys" || Mnemonic == "fdivs" || Mnemonic == "fmuls" ||
+ Mnemonic == "fcmps" || Mnemonic == "fcmpzs" || Mnemonic == "vfms" ||
+ Mnemonic == "vfnms" || Mnemonic == "fconsts" || Mnemonic == "bxns" ||
+ Mnemonic == "blxns" || Mnemonic == "vfmas" || Mnemonic == "vmlas" ||
(Mnemonic == "movs" && isThumb()))) {
Mnemonic = Mnemonic.slice(0, Mnemonic.size() - 1);
CarrySetting = true;
@@ -6405,8 +6398,7 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic,
if (Mnemonic.starts_with("vpst")) {
ITMask = Mnemonic.slice(4, Mnemonic.size());
Mnemonic = Mnemonic.slice(0, 4);
- }
- else if (Mnemonic.starts_with("vpt")) {
+ } else if (Mnemonic.starts_with("vpt")) {
ITMask = Mnemonic.slice(3, Mnemonic.size());
Mnemonic = Mnemonic.slice(0, 3);
}
@@ -6446,24 +6438,21 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic,
Mnemonic == "vminnm" || Mnemonic == "vcvta" || Mnemonic == "vcvtn" ||
Mnemonic == "vcvtp" || Mnemonic == "vcvtm" || Mnemonic == "vrinta" ||
Mnemonic == "vrintn" || Mnemonic == "vrintp" || Mnemonic == "vrintm" ||
- Mnemonic.starts_with("aes") || Mnemonic == "hvc" || Mnemonic == "setpan" ||
- Mnemonic.starts_with("sha1") || Mnemonic.starts_with("sha256") ||
+ Mnemonic.starts_with("aes") || Mnemonic == "hvc" ||
+ Mnemonic == "setpan" || Mnemonic.starts_with("sha1") ||
+ Mnemonic.starts_with("sha256") ||
(FullInst.starts_with("vmull") && FullInst.ends_with(".p64")) ||
- Mnemonic == "vmovx" || Mnemonic == "vins" ||
- Mnemonic == "vudot" || Mnemonic == "vsdot" ||
- Mnemonic == "vcmla" || Mnemonic == "vcadd" ||
- Mnemonic == "vfmal" || Mnemonic == "vfmsl" ||
- Mnemonic == "vfmat" || Mnemonic == "vfmab" ||
- Mnemonic == "vdot" || Mnemonic == "vmmla" ||
- Mnemonic == "sb" || Mnemonic == "ssbb" ||
- Mnemonic == "pssbb" || Mnemonic == "vsmmla" ||
- Mnemonic == "vummla" || Mnemonic == "vusmmla" ||
- Mnemonic == "vusdot" || Mnemonic == "vsudot" ||
- Mnemonic == "bfcsel" || Mnemonic == "wls" ||
- Mnemonic == "dls" || Mnemonic == "le" || Mnemonic == "csel" ||
- Mnemonic == "csinc" || Mnemonic == "csinv" || Mnemonic == "csneg" ||
- Mnemonic == "cinc" || Mnemonic == "cinv" || Mnemonic == "cneg" ||
- Mnemonic == "cset" || Mnemonic == "csetm" ||
+ Mnemonic == "vmovx" || Mnemonic == "vins" || Mnemonic == "vudot" ||
+ Mnemonic == "vsdot" || Mnemonic == "vcmla" || Mnemonic == "vcadd" ||
+ Mnemonic == "vfmal" || Mnemonic == "vfmsl" || Mnemonic == "vfmat" ||
+ Mnemonic == "vfmab" || Mnemonic == "vdot" || Mnemonic == "vmmla" ||
+ Mnemonic == "sb" || Mnemonic == "ssbb" || Mnemonic == "pssbb" ||
+ Mnemonic == "vsmmla" || Mnemonic == "vummla" || Mnemonic == "vusmmla" ||
+ Mnemonic == "vusdot" || Mnemonic == "vsudot" || Mnemonic == "bfcsel" ||
+ Mnemonic == "wls" || Mnemonic == "dls" || Mnemonic == "le" ||
+ Mnemonic == "csel" || Mnemonic == "csinc" || Mnemonic == "csinv" ||
+ Mnemonic == "csneg" || Mnemonic == "cinc" || Mnemonic == "cinv" ||
+ Mnemonic == "cneg" || Mnemonic == "cset" || Mnemonic == "csetm" ||
(hasCDE() && MS.isCDEInstr(Mnemonic) &&
!MS.isITPredicableCDEInstr(Mnemonic)) ||
Mnemonic.starts_with("vpt") || Mnemonic.starts_with("vpst") ||
@@ -6484,8 +6473,7 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic,
Mnemonic != "dmb" && Mnemonic != "dfb" && Mnemonic != "dsb" &&
Mnemonic != "isb" && Mnemonic != "pld" && Mnemonic != "pli" &&
Mnemonic != "pldw" && Mnemonic != "ldc2" && Mnemonic != "ldc2l" &&
- Mnemonic != "stc2" && Mnemonic != "stc2l" &&
- Mnemonic != "tsb" &&
+ Mnemonic != "stc2" && Mnemonic != "stc2l" && Mnemonic != "tsb" &&
!Mnemonic.starts_with("rfe") && !Mnemonic.starts_with("srs");
} else if (isThumbOne()) {
if (hasV6MOps())
@@ -7228,7 +7216,8 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// operand if that is the case.
else if (Mnemonic == "vmov" || Mnemonic.starts_with("vcmp") ||
(Mnemonic.starts_with("vcvt") && !Mnemonic.starts_with("vcvta") &&
- !Mnemonic.starts_with("vcvtn") && !Mnemonic.starts_with("vcvtp") &&
+ !Mnemonic.starts_with("vcvtn") &&
+ !Mnemonic.starts_with("vcvtp") &&
!Mnemonic.starts_with("vcvtm"))) {
if (!shouldOmitVectorPredicateOperand(Mnemonic, Operands)) {
// We could not split the vector predicate off vcvt because it might
@@ -7241,7 +7230,7 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
auto Sz1 = static_cast<ARMOperand &>(*Operands[2]);
auto Sz2 = static_cast<ARMOperand &>(*Operands[3]);
if (!(Sz1.isToken() && Sz1.getToken().starts_with(".f") &&
- Sz2.isToken() && Sz2.getToken().starts_with(".f"))) {
+ Sz2.isToken() && Sz2.getToken().starts_with(".f"))) {
Operands.erase(Operands.begin());
SMLoc MLoc = SMLoc::getFromPointer(NameLoc.getPointer());
VPTPredicationCode = ARMVCC::Then;
diff --git a/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp b/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
index 42287758c962d..21d5f7653a689 100644
--- a/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
+++ b/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
@@ -932,8 +932,10 @@ StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
Mnemonic = parseRD(Name, 10, NameLoc, Operands);
} else if (Name.starts_with("cvt.l.d")) {
Mnemonic = parseRD(Name, 7, NameLoc, Operands);
- } else if (Name.starts_with("vcvt.w.d.sx") || Name.starts_with("vcvt.w.d.zx") ||
- Name.starts_with("vcvt.w.s.sx") || Name.starts_with("vcvt.w.s.zx")) {
+ } else if (Name.starts_with("vcvt.w.d.sx") ||
+ Name.starts_with("vcvt.w.d.zx") ||
+ Name.starts_with("vcvt.w.s.sx") ||
+ Name.starts_with("vcvt.w.s.zx")) {
Mnemonic = parseRD(Name, 11, NameLoc, Operands);
} else if (Name.starts_with("vcvt.l.d")) {
Mnemonic = parseRD(Name, 8, NameLoc, Operands);
@@ -946,8 +948,10 @@ StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
Name.starts_with("vfmk.d.") || Name.starts_with("vfmk.s.")) {
bool ICC = Name[5] == 'l' || Name[5] == 'w' ? true : false;
Mnemonic = parseCC(Name, 7, Name.size(), ICC, true, NameLoc, Operands);
- } else if (Name.starts_with("pvfmk.w.lo.") || Name.starts_with("pvfmk.w.up.") ||
- Name.starts_with("pvfmk.s.lo.") || Name.starts_with("pvfmk.s.up.")) {
+ } else if (Name.starts_with("pvfmk.w.lo.") ||
+ Name.starts_with("pvfmk.w.up.") ||
+ Name.starts_with("pvfmk.s.lo.") ||
+ Name.starts_with("pvfmk.s.up.")) {
bool ICC = Name[6] == 'l' || Name[6] == 'w' ? true : false;
Mnemonic = parseCC(Name, 11, Name.size(), ICC, true, NameLoc, Operands);
} else {
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index a01d710d6a4f9..e78d160564601 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3334,7 +3334,6 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
}
-
// Determine whether this is an instruction prefix.
// FIXME:
// Enhance prefixes integrity robustness. for example, following forms
diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
index f1904ea159bf1..73c0f5430d80d 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -211,8 +211,8 @@ static const char *isInvalidOpcode(const Instruction &Instr) {
if ((Instr.Description.TSFlags & X86II::FormMask) == X86II::Pseudo)
return "unsupported opcode: pseudo instruction";
if ((OpcodeName.starts_with("POP") && !OpcodeName.starts_with("POPCNT")) ||
- OpcodeName.starts_with("PUSH") || OpcodeName.starts_with("ADJCALLSTACK") ||
- OpcodeName.starts_with("LEAVE"))
+ OpcodeName.starts_with("PUSH") ||
+ OpcodeName.starts_with("ADJCALLSTACK") || OpcodeName.starts_with("LEAVE"))
return "unsupported opcode: Push/Pop/AdjCallStack/Leave";
switch (Instr.Description.Opcode) {
case X86::LFS16rm:
More information about the llvm-commits
mailing list