Skip to content

Commit d14d706

Browse files
[llvm] Use StringRef::contains (NFC)
1 parent 878060a commit d14d706

File tree

12 files changed

+18
-19
lines changed

12 files changed

+18
-19
lines changed

llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,10 @@ inline bool IsObjCIdentifiedObject(const Value *V) {
204204
return true;
205205

206206
StringRef Section = GV->getSection();
207-
if (Section.find("__message_refs") != StringRef::npos ||
208-
Section.find("__objc_classrefs") != StringRef::npos ||
209-
Section.find("__objc_superrefs") != StringRef::npos ||
210-
Section.find("__objc_methname") != StringRef::npos ||
211-
Section.find("__cstring") != StringRef::npos)
207+
if (Section.contains("__message_refs") ||
208+
Section.contains("__objc_classrefs") ||
209+
Section.contains("__objc_superrefs") ||
210+
Section.contains("__objc_methname") || Section.contains("__cstring"))
212211
return true;
213212
}
214213
}

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
883883
static StringRef sanitizeFunctionName(StringRef funcName) {
884884
// Filter out empty names and names containing null bytes, those can't be in
885885
// our table.
886-
if (funcName.empty() || funcName.find('\0') != StringRef::npos)
886+
if (funcName.empty() || funcName.contains('\0'))
887887
return StringRef();
888888

889889
// Check for \01 prefix that is used to mangle __asm declarations and

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static bool hasObjCCategory(StringRef Name) {
480480
if (!isObjCClass(Name))
481481
return false;
482482

483-
return Name.find(") ") != StringRef::npos;
483+
return Name.contains(") ");
484484
}
485485

486486
static void getObjCClassCategory(StringRef In, StringRef &Class,

llvm/lib/FileCheck/FileCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,8 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
954954

955955
// Check to see if this is a fixed string, or if it has regex pieces.
956956
if (!MatchFullLinesHere &&
957-
(PatternStr.size() < 2 || (PatternStr.find("{{") == StringRef::npos &&
958-
PatternStr.find("[[") == StringRef::npos))) {
957+
(PatternStr.size() < 2 ||
958+
(!PatternStr.contains("{{") && !PatternStr.contains("[[")))) {
959959
FixedStr = PatternStr;
960960
return false;
961961
}

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
603603

604604
auto fArgs = F->getFunctionType()->params();
605605
Type *Tys[] = {fArgs[0], fArgs[1]};
606-
if (Name.find("lane") == StringRef::npos)
606+
if (!Name.contains("lane"))
607607
NewFn = Intrinsic::getDeclaration(F->getParent(),
608608
StoreInts[fArgs.size() - 3], Tys);
609609
else

llvm/lib/IR/Constants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,7 @@ bool ConstantDataSequential::isCString() const {
32943294
if (Str.back() != 0) return false;
32953295

32963296
// Other elements must be non-nul.
3297-
return Str.drop_back().find(0) == StringRef::npos;
3297+
return !Str.drop_back().contains(0);
32983298
}
32993299

33003300
bool ConstantDataVector::isSplatData() const {

llvm/lib/InterfaceStub/IFSHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bool usesTriple(StringRef Buf) {
163163
for (line_iterator I(MemoryBufferRef(Buf, "ELFStub")); !I.is_at_eof(); ++I) {
164164
StringRef Line = (*I).trim();
165165
if (Line.startswith("Target:")) {
166-
if (Line == "Target:" || (Line.find("{") != Line.npos)) {
166+
if (Line == "Target:" || Line.contains("{")) {
167167
return false;
168168
}
169169
}

llvm/lib/MC/MCParser/ELFAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
830830
if (getParser().parseIdentifier(Name))
831831
return TokError("expected identifier in directive");
832832

833-
if (Name.find('@') == StringRef::npos)
833+
if (!Name.contains('@'))
834834
return TokError("expected a '@' in the name");
835835
bool KeepOriginalSym = !Name.contains("@@@");
836836
if (parseOptionalToken(AsmToken::Comma)) {

llvm/lib/ProfileData/InstrProfWriter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ void InstrProfWriter::overlapRecord(NamedInstrProfRecord &&Other,
215215
InstrProfRecord &Dest = Where->second;
216216

217217
uint64_t ValueCutoff = FuncFilter.ValueCutoff;
218-
if (!FuncFilter.NameFilter.empty() &&
219-
Name.find(FuncFilter.NameFilter) != Name.npos)
218+
if (!FuncFilter.NameFilter.empty() && Name.contains(FuncFilter.NameFilter))
220219
ValueCutoff = 0;
221220

222221
Dest.overlap(Other, Overlap, FuncLevelOverlap, ValueCutoff);

llvm/lib/ProfileData/SampleProfWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ std::error_code SampleProfileWriterExtBinaryBase::writeNameTableSection(
240240
// so compiler won't strip the suffix during profile matching after
241241
// seeing the flag in the profile.
242242
for (const auto &I : NameTable) {
243-
if (I.first.find(FunctionSamples::UniqSuffix) != StringRef::npos) {
243+
if (I.first.contains(FunctionSamples::UniqSuffix)) {
244244
addSectionFlag(SecNameTable, SecNameTableFlags::SecFlagUniqSuffix);
245245
break;
246246
}

llvm/lib/Support/ARMTargetParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
307307
else if (A.startswith("aarch64")) {
308308
offset = 7;
309309
// AArch64 uses "_be", not "eb" suffix.
310-
if (A.find("eb") != StringRef::npos)
310+
if (A.contains("eb"))
311311
return Error;
312312
if (A.substr(offset, 3) == "_be")
313313
offset += 3;
@@ -333,7 +333,7 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
333333
if (A.size() >= 2 && (A[0] != 'v' || !std::isdigit(A[1])))
334334
return Error;
335335
// Can't have an extra 'eb'.
336-
if (A.find("eb") != StringRef::npos)
336+
if (A.contains("eb"))
337337
return Error;
338338
}
339339

llvm/lib/Support/Unix/Program.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
7171
assert(!Name.empty() && "Must have a name!");
7272
// Use the given path verbatim if it contains any slashes; this matches
7373
// the behavior of sh(1) and friends.
74-
if (Name.find('/') != StringRef::npos) return std::string(Name);
74+
if (Name.contains('/'))
75+
return std::string(Name);
7576

7677
SmallVector<StringRef, 16> EnvironmentPaths;
7778
if (Paths.empty())

0 commit comments

Comments
 (0)