Skip to content

Commit b65da98

Browse files
committed
[AsmPrinter] Use StringRef::starts_with/ends_with instead of startswith/endswith. NFC.
startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
1 parent 939fd6c commit b65da98

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,8 @@ bool AsmPrinter::doFinalization(Module &M) {
23892389
OutStreamer->emitAddrsig();
23902390
for (const GlobalValue &GV : M.global_values()) {
23912391
if (!GV.use_empty() && !GV.isThreadLocal() &&
2392-
!GV.hasDLLImportStorageClass() && !GV.getName().startswith("llvm.") &&
2392+
!GV.hasDLLImportStorageClass() &&
2393+
!GV.getName().starts_with("llvm.") &&
23932394
!GV.hasAtLeastLocalUnnamedAddr())
23942395
OutStreamer->emitAddrsigSym(getSymbol(&GV));
23952396
}

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
142142

143143
// If this is a Unix-style path, just use it as is. Don't try to canonicalize
144144
// it textually because one of the path components could be a symlink.
145-
if (Dir.startswith("/") || Filename.startswith("/")) {
145+
if (Dir.starts_with("/") || Filename.starts_with("/")) {
146146
if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix))
147147
return Filename;
148148
Filepath = std::string(Dir);
@@ -910,10 +910,10 @@ static std::string flattenCommandLine(ArrayRef<std::string> Args,
910910
i++; // Skip this argument and next one.
911911
continue;
912912
}
913-
if (Arg.startswith("-object-file-name") || Arg == MainFilename)
913+
if (Arg.starts_with("-object-file-name") || Arg == MainFilename)
914914
continue;
915915
// Skip fmessage-length for reproduciability.
916-
if (Arg.startswith("-fmessage-length"))
916+
if (Arg.starts_with("-fmessage-length"))
917917
continue;
918918
if (PrintedOneArg)
919919
OS << " ";
@@ -2583,7 +2583,7 @@ CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) {
25832583

25842584
// Virtual function pointer member.
25852585
if ((Member->getFlags() & DINode::FlagArtificial) &&
2586-
Member->getName().startswith("_vptr$")) {
2586+
Member->getName().starts_with("_vptr$")) {
25872587
VFPtrRecord VFPR(getTypeIndex(Member->getBaseType()));
25882588
ContinuationBuilder.writeMemberType(VFPR);
25892589
MemberCount++;

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
445445
DwarfDebug::~DwarfDebug() = default;
446446

447447
static bool isObjCClass(StringRef Name) {
448-
return Name.startswith("+") || Name.startswith("-");
448+
return Name.starts_with("+") || Name.starts_with("-");
449449
}
450450

451451
static bool hasObjCCategory(StringRef Name) {

llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static bool isPossibleIndirectCallTarget(const Function *F) {
7575
}
7676

7777
MCSymbol *WinCFGuard::lookupImpSymbol(const MCSymbol *Sym) {
78-
if (Sym->getName().startswith("__imp_"))
78+
if (Sym->getName().starts_with("__imp_"))
7979
return nullptr;
8080
return Asm->OutContext.lookupSymbol(Twine("__imp_") + Sym->getName());
8181
}

0 commit comments

Comments
 (0)