Skip to content

Commit 6fe949c

Browse files
[Target, Transforms] Use StringRef::contains (NFC)
1 parent 12b44bf commit 6fe949c

File tree

9 files changed

+24
-26
lines changed

9 files changed

+24
-26
lines changed

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3351,7 +3351,7 @@ void AArch64AsmParser::createSysAlias(uint16_t Encoding, OperandVector &Operands
33513351
/// the SYS instruction. Parse them specially so that we create a SYS MCInst.
33523352
bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc,
33533353
OperandVector &Operands) {
3354-
if (Name.find('.') != StringRef::npos)
3354+
if (Name.contains('.'))
33553355
return TokError("invalid operand");
33563356

33573357
Mnemonic = Name;

llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ MetadataStreamerV2::getAddressSpaceQualifier(
113113

114114
ValueKind MetadataStreamerV2::getValueKind(Type *Ty, StringRef TypeQual,
115115
StringRef BaseTypeName) const {
116-
if (TypeQual.find("pipe") != StringRef::npos)
116+
if (TypeQual.contains("pipe"))
117117
return ValueKind::Pipe;
118118

119119
return StringSwitch<ValueKind>(BaseTypeName)
@@ -533,7 +533,7 @@ MetadataStreamerV3::getAddressSpaceQualifier(unsigned AddressSpace) const {
533533

534534
StringRef MetadataStreamerV3::getValueKind(Type *Ty, StringRef TypeQual,
535535
StringRef BaseTypeName) const {
536-
if (TypeQual.find("pipe") != StringRef::npos)
536+
if (TypeQual.contains("pipe"))
537537
return "pipe";
538538

539539
return StringSwitch<StringRef>(BaseTypeName)

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,8 +1371,7 @@ bool AMDGPULibCalls::fold_wavefrontsize(CallInst *CI, IRBuilder<> &B) {
13711371
StringRef CPU = TM->getTargetCPU();
13721372
StringRef Features = TM->getTargetFeatureString();
13731373
if ((CPU.empty() || CPU.equals_insensitive("generic")) &&
1374-
(Features.empty() ||
1375-
Features.find_insensitive("wavefrontsize") == StringRef::npos))
1374+
(Features.empty() || !Features.contains_insensitive("wavefrontsize")))
13761375
return false;
13771376

13781377
Function *F = CI->getParent()->getParent();

llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ GCNSubtarget::initializeSubtargetDependencies(const Triple &TT,
8282
FullFS += "+enable-prt-strict-null,"; // This is overridden by a disable in FS
8383

8484
// Disable mutually exclusive bits.
85-
if (FS.find_insensitive("+wavefrontsize") != StringRef::npos) {
86-
if (FS.find_insensitive("wavefrontsize16") == StringRef::npos)
85+
if (FS.contains_insensitive("+wavefrontsize")) {
86+
if (!FS.contains_insensitive("wavefrontsize16"))
8787
FullFS += "-wavefrontsize16,";
88-
if (FS.find_insensitive("wavefrontsize32") == StringRef::npos)
88+
if (!FS.contains_insensitive("wavefrontsize32"))
8989
FullFS += "-wavefrontsize32,";
90-
if (FS.find_insensitive("wavefrontsize64") == StringRef::npos)
90+
if (!FS.contains_insensitive("wavefrontsize64"))
9191
FullFS += "-wavefrontsize64,";
9292
}
9393

llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ static bool isSmallDataSection(StringRef Sec) {
9090
return true;
9191
// If either ".sdata." or ".sbss." is a substring of the section name
9292
// then put the symbol in small data.
93-
return Sec.find(".sdata.") != StringRef::npos ||
94-
Sec.find(".sbss.") != StringRef::npos ||
95-
Sec.find(".scommon.") != StringRef::npos;
93+
return Sec.contains(".sdata.") || Sec.contains(".sbss.") ||
94+
Sec.contains(".scommon.");
9695
}
9796

9897
static const char *getSectionSuffixForSize(unsigned Size) {
@@ -178,10 +177,10 @@ MCSection *HexagonTargetObjectFile::getExplicitSectionGlobal(
178177

179178
if (GO->hasSection()) {
180179
StringRef Section = GO->getSection();
181-
if (Section.find(".access.text.group") != StringRef::npos)
180+
if (Section.contains(".access.text.group"))
182181
return getContext().getELFSection(GO->getSection(), ELF::SHT_PROGBITS,
183182
ELF::SHF_ALLOC | ELF::SHF_EXECINSTR);
184-
if (Section.find(".access.data.group") != StringRef::npos)
183+
if (Section.contains(".access.data.group"))
185184
return getContext().getELFSection(GO->getSection(), ELF::SHT_PROGBITS,
186185
ELF::SHF_WRITE | ELF::SHF_ALLOC);
187186
}

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
431431

432432
bool checkForP2AlignIfLoadStore(OperandVector &Operands, StringRef InstName) {
433433
// FIXME: there is probably a cleaner way to do this.
434-
auto IsLoadStore = InstName.find(".load") != StringRef::npos ||
435-
InstName.find(".store") != StringRef::npos ||
436-
InstName.find("prefetch") != StringRef::npos;
437-
auto IsAtomic = InstName.find("atomic.") != StringRef::npos;
434+
auto IsLoadStore = InstName.contains(".load") ||
435+
InstName.contains(".store") ||
436+
InstName.contains("prefetch");
437+
auto IsAtomic = InstName.contains("atomic.");
438438
if (IsLoadStore || IsAtomic) {
439439
// Parse load/store operands of the form: offset:p2align=align
440440
if (IsLoadStore && isNext(AsmToken::Colon)) {
@@ -450,7 +450,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
450450
// v128.{load,store}{8,16,32,64}_lane has both a memarg and a lane
451451
// index. We need to avoid parsing an extra alignment operand for the
452452
// lane index.
453-
auto IsLoadStoreLane = InstName.find("_lane") != StringRef::npos;
453+
auto IsLoadStoreLane = InstName.contains("_lane");
454454
if (IsLoadStoreLane && Operands.size() == 4)
455455
return false;
456456
// Alignment not specified (or atomics, must use default alignment).

llvm/lib/Target/X86/X86FrameLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,8 +3104,7 @@ void X86FrameLowering::adjustForHiPEPrologue(
31043104
// having a ".", such as a simple <Module>.<Function>.<Arity>, or an
31053105
// "_", such as the BIF "suspend_0") as they are executed on another
31063106
// stack.
3107-
if (F->getName().find("erlang.") != StringRef::npos ||
3108-
F->getName().find("bif_") != StringRef::npos ||
3107+
if (F->getName().contains("erlang.") || F->getName().contains("bif_") ||
31093108
F->getName().find_first_of("._") == StringRef::npos)
31103109
continue;
31113110

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,8 @@ bool ModuleAddressSanitizer::shouldInstrumentGlobal(GlobalVariable *G) const {
20032003
// Globals from llvm.metadata aren't emitted, do not instrument them.
20042004
if (Section == "llvm.metadata") return false;
20052005
// Do not instrument globals from special LLVM sections.
2006-
if (Section.find("__llvm") != StringRef::npos || Section.find("__LLVM") != StringRef::npos) return false;
2006+
if (Section.contains("__llvm") || Section.contains("__LLVM"))
2007+
return false;
20072008

20082009
// Do not instrument function pointers to initialization and termination
20092010
// routines: dynamic linker will not properly handle redzones.

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ Value *LibCallSimplifier::optimizePrintFString(CallInst *CI, IRBuilderBase &B) {
23512351

23522352
// printf("foo\n") --> puts("foo")
23532353
if (FormatStr.back() == '\n' &&
2354-
FormatStr.find('%') == StringRef::npos) { // No format characters.
2354+
!FormatStr.contains('%')) { // No format characters.
23552355
// Create a string literal with no \n on it. We expect the constant merge
23562356
// pass to be run after this pass, to merge duplicate strings.
23572357
FormatStr = FormatStr.drop_back();
@@ -2421,7 +2421,7 @@ Value *LibCallSimplifier::optimizeSPrintFString(CallInst *CI,
24212421
if (CI->arg_size() == 2) {
24222422
// Make sure there's no % in the constant array. We could try to handle
24232423
// %% -> % in the future if we cared.
2424-
if (FormatStr.find('%') != StringRef::npos)
2424+
if (FormatStr.contains('%'))
24252425
return nullptr; // we found a format specifier, bail out.
24262426

24272427
// sprintf(str, fmt) -> llvm.memcpy(align 1 str, align 1 fmt, strlen(fmt)+1)
@@ -2548,7 +2548,7 @@ Value *LibCallSimplifier::optimizeSnPrintFString(CallInst *CI,
25482548
if (CI->arg_size() == 3) {
25492549
// Make sure there's no % in the constant array. We could try to handle
25502550
// %% -> % in the future if we cared.
2551-
if (FormatStr.find('%') != StringRef::npos)
2551+
if (FormatStr.contains('%'))
25522552
return nullptr; // we found a format specifier, bail out.
25532553

25542554
if (N == 0)
@@ -2637,7 +2637,7 @@ Value *LibCallSimplifier::optimizeFPrintFString(CallInst *CI,
26372637
// fprintf(F, "foo") --> fwrite("foo", 3, 1, F)
26382638
if (CI->arg_size() == 2) {
26392639
// Could handle %% -> % if we cared.
2640-
if (FormatStr.find('%') != StringRef::npos)
2640+
if (FormatStr.contains('%'))
26412641
return nullptr; // We found a format specifier.
26422642

26432643
return emitFWrite(

0 commit comments

Comments
 (0)