-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm] Use StringRef::{starts,ends}_with (NFC) #74956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm] Use StringRef::{starts,ends}_with (NFC) #74956
Conversation
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/pr-subscribers-backend-loongarch @llvm/pr-subscribers-backend-arm Author: Kazu Hirata (kazutakahirata) ChangesThis patch replaces uses of StringRef::{starts,ends}with with I'm planning to deprecate and eventually remove Patch is 234.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74956.diff 191 Files Affected:
diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
index 20ff5a5bc6e034..ccf859922e1634 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 b0a8e3043be5cc..9b064ab788bf78 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 bf35febb805762..bb8dbb0478ff54 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 373863e21ff02e..2faf84f0372cb0 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 8e16fc148a3c78..761c532b9bf1f4 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 19ac90842bcb08..61417431f8a8f3 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 f001f5ee9d39b6..d995cc69af894a 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 97b18e51beeeeb..50167708163ef0 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 7567efbedfb027..87ddfe3e92ae9a 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 92af314a41caad..ad918ef7245b00 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 919c69fe2783e7..fcb25f5f1d49df 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 420224df57df41..255937a5bdd04a 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 1a4b55ea381826..910e97489dbbe0 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 96662378a86931..15b6f63e86327a 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 339019923c00bd..ab4b26e294106d 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 0a0e386cde6100..870611248466f5 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 cc29bdce1210f6..9002a707684018 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 9827bd3ff4f1ba..c71ba4d71efaf5 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.star...
[truncated]
|
@llvm/pr-subscribers-backend-risc-v Author: Kazu Hirata (kazutakahirata) ChangesThis patch replaces uses of StringRef::{starts,ends}with with I'm planning to deprecate and eventually remove Patch is 234.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74956.diff 191 Files Affected:
diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
index 20ff5a5bc6e034..ccf859922e1634 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 b0a8e3043be5cc..9b064ab788bf78 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 bf35febb805762..bb8dbb0478ff54 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 373863e21ff02e..2faf84f0372cb0 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 8e16fc148a3c78..761c532b9bf1f4 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 19ac90842bcb08..61417431f8a8f3 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 f001f5ee9d39b6..d995cc69af894a 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 97b18e51beeeeb..50167708163ef0 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 7567efbedfb027..87ddfe3e92ae9a 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 92af314a41caad..ad918ef7245b00 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 919c69fe2783e7..fcb25f5f1d49df 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 420224df57df41..255937a5bdd04a 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 1a4b55ea381826..910e97489dbbe0 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 96662378a86931..15b6f63e86327a 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 339019923c00bd..ab4b26e294106d 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 0a0e386cde6100..870611248466f5 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 cc29bdce1210f6..9002a707684018 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 9827bd3ff4f1ba..c71ba4d71efaf5 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.star...
[truncated]
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I couldn't see any clang-format warnings that were particularly severe (just code alignment etc.) - its up to you if you format them or not.
Most of those are about 80 characters/line. |
@felipepiovezan How can you tell? The bot's stderr doesn't seem to tell you and the ones I could see were the typical cases where lines had been manually indented to align. |
Looking at some random output from the bot:
The line where
Same here for the line where And then there are some cases where the previous code was already offending the formatter:
These ones we can probably ignore, but if we're changing those lines anyway.. might as well make the formatter happy. |
A good point. I just ran clang-format on the whole thing. |
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.