[llvm] b2e487d - [llvm] Use StringRef::contains (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 17:38:43 PDT 2023
Author: Kazu Hirata
Date: 2023-10-18T17:38:37-07:00
New Revision: b2e487d1f963d386e35fccf97af40fd87540e9b6
URL: https://github.com/llvm/llvm-project/commit/b2e487d1f963d386e35fccf97af40fd87540e9b6
DIFF: https://github.com/llvm/llvm-project/commit/b2e487d1f963d386e35fccf97af40fd87540e9b6.diff
LOG: [llvm] Use StringRef::contains (NFC)
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/unittests/MC/DwarfLineTableHeaders.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 97d2fe3426406f3..072c55f79caa9dc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1524,7 +1524,7 @@ void AsmPrinter::emitPCSections(const MachineFunction &MF) {
const size_t OptStart = SecWithOpt.find('!'); // likely npos
const StringRef Sec = SecWithOpt.substr(0, OptStart);
const StringRef Opts = SecWithOpt.substr(OptStart); // likely empty
- ConstULEB128 = Opts.find('C') != StringRef::npos;
+ ConstULEB128 = Opts.contains('C');
#ifndef NDEBUG
for (char O : Opts)
assert((O == '!' || O == 'C') && "Invalid !pcsections options");
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index ae5ba6b13a1bd74..cbcb49c3e2d74dc 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -7488,7 +7488,7 @@ bool AArch64AsmParser::parseAuthExpr(const MCExpr *&Res, SMLoc &EndLoc) {
// Look for '_sym at AUTH' ...
if (Tok.is(AsmToken::Identifier) && Tok.getIdentifier().endswith("@AUTH")) {
StringRef SymName = Tok.getIdentifier().drop_back(strlen("@AUTH"));
- if (SymName.find('@') != StringRef::npos)
+ if (SymName.contains('@'))
return TokError(
"combination of @AUTH with other modifiers not supported");
Res = MCSymbolRefExpr::create(Ctx.getOrCreateSymbol(SymName), Ctx);
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 586119a10b4f3cb..29e4cf1d5126cdc 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5565,7 +5565,7 @@ static AMDGPUNote getAMDGPUNote(uint32_t NoteType, ArrayRef<uint8_t> Desc) {
// FIXME: Metadata Verifier only works with AMDHSA.
// This is an ugly workaround to avoid the verifier for other MD
// formats (e.g. amdpal)
- if (MsgPackString.find("amdhsa.") != StringRef::npos) {
+ if (MsgPackString.contains("amdhsa.")) {
AMDGPU::HSAMD::V3::MetadataVerifier Verifier(true);
if (!Verifier.verify(MsgPackDoc.getRoot()))
MetadataString = "Invalid AMDGPU Metadata\n";
diff --git a/llvm/unittests/MC/DwarfLineTableHeaders.cpp b/llvm/unittests/MC/DwarfLineTableHeaders.cpp
index ed3671aa6c97e72..691d319f5409896 100644
--- a/llvm/unittests/MC/DwarfLineTableHeaders.cpp
+++ b/llvm/unittests/MC/DwarfLineTableHeaders.cpp
@@ -172,8 +172,8 @@ class DwarfLineTableHeaders : public ::testing::Test {
Expected<StringRef> ContentsOrErr = Section.getContents();
ASSERT_TRUE(static_cast<bool>(ContentsOrErr));
StringRef Contents = *ContentsOrErr;
- ASSERT_TRUE(Contents.find("dir") != StringRef::npos);
- ASSERT_TRUE(Contents.find("file") != StringRef::npos);
+ ASSERT_TRUE(Contents.contains("dir"));
+ ASSERT_TRUE(Contents.contains("file"));
ASSERT_TRUE(Contents.size() == 9);
return;
}
More information about the llvm-commits
mailing list