[llvm] d14d706 - [llvm] Use StringRef::contains (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 23 08:45:51 PDT 2021
Author: Kazu Hirata
Date: 2021-10-23T08:45:27-07:00
New Revision: d14d7068b6b4a141f33edd7f135da238b580cca6
URL: https://github.com/llvm/llvm-project/commit/d14d7068b6b4a141f33edd7f135da238b580cca6
DIFF: https://github.com/llvm/llvm-project/commit/d14d7068b6b4a141f33edd7f135da238b580cca6.diff
LOG: [llvm] Use StringRef::contains (NFC)
Added:
Modified:
llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/FileCheck/FileCheck.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/InterfaceStub/IFSHandler.cpp
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/lib/ProfileData/InstrProfWriter.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Support/Unix/Program.inc
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
index 62bdade95d960..8402b6465104c 100644
--- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
+++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
@@ -204,11 +204,10 @@ inline bool IsObjCIdentifiedObject(const Value *V) {
return true;
StringRef Section = GV->getSection();
- if (Section.find("__message_refs") != StringRef::npos ||
- Section.find("__objc_classrefs") != StringRef::npos ||
- Section.find("__objc_superrefs") != StringRef::npos ||
- Section.find("__objc_methname") != StringRef::npos ||
- Section.find("__cstring") != StringRef::npos)
+ if (Section.contains("__message_refs") ||
+ Section.contains("__objc_classrefs") ||
+ Section.contains("__objc_superrefs") ||
+ Section.contains("__objc_methname") || Section.contains("__cstring"))
return true;
}
}
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 5dc2245368362..7326ba74c0713 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -883,7 +883,7 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
static StringRef sanitizeFunctionName(StringRef funcName) {
// Filter out empty names and names containing null bytes, those can't be in
// our table.
- if (funcName.empty() || funcName.find('\0') != StringRef::npos)
+ if (funcName.empty() || funcName.contains('\0'))
return StringRef();
// Check for \01 prefix that is used to mangle __asm declarations and
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b76be120df13d..9388cd6fce69c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -480,7 +480,7 @@ static bool hasObjCCategory(StringRef Name) {
if (!isObjCClass(Name))
return false;
- return Name.find(") ") != StringRef::npos;
+ return Name.contains(") ");
}
static void getObjCClassCategory(StringRef In, StringRef &Class,
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index d4326ef7981b6..c962231cbdc16 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -954,8 +954,8 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
// Check to see if this is a fixed string, or if it has regex pieces.
if (!MatchFullLinesHere &&
- (PatternStr.size() < 2 || (PatternStr.find("{{") == StringRef::npos &&
- PatternStr.find("[[") == StringRef::npos))) {
+ (PatternStr.size() < 2 ||
+ (!PatternStr.contains("{{") && !PatternStr.contains("[[")))) {
FixedStr = PatternStr;
return false;
}
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index fc5c59cba9741..d73d1e9c20b3b 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -603,7 +603,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
auto fArgs = F->getFunctionType()->params();
Type *Tys[] = {fArgs[0], fArgs[1]};
- if (Name.find("lane") == StringRef::npos)
+ if (!Name.contains("lane"))
NewFn = Intrinsic::getDeclaration(F->getParent(),
StoreInts[fArgs.size() - 3], Tys);
else
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index a7a191810c765..0b4334442d4fa 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -3294,7 +3294,7 @@ bool ConstantDataSequential::isCString() const {
if (Str.back() != 0) return false;
// Other elements must be non-nul.
- return Str.drop_back().find(0) == StringRef::npos;
+ return !Str.drop_back().contains(0);
}
bool ConstantDataVector::isSplatData() const {
diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp
index bfee204e4642a..e6bf09232ce20 100644
--- a/llvm/lib/InterfaceStub/IFSHandler.cpp
+++ b/llvm/lib/InterfaceStub/IFSHandler.cpp
@@ -163,7 +163,7 @@ bool usesTriple(StringRef Buf) {
for (line_iterator I(MemoryBufferRef(Buf, "ELFStub")); !I.is_at_eof(); ++I) {
StringRef Line = (*I).trim();
if (Line.startswith("Target:")) {
- if (Line == "Target:" || (Line.find("{") != Line.npos)) {
+ if (Line == "Target:" || Line.contains("{")) {
return false;
}
}
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index fdaacb572f062..ddc41d0a08ab5 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -830,7 +830,7 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
if (getParser().parseIdentifier(Name))
return TokError("expected identifier in directive");
- if (Name.find('@') == StringRef::npos)
+ if (!Name.contains('@'))
return TokError("expected a '@' in the name");
bool KeepOriginalSym = !Name.contains("@@@");
if (parseOptionalToken(AsmToken::Comma)) {
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 987c0b175d3cb..1c897570135e0 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -215,8 +215,7 @@ void InstrProfWriter::overlapRecord(NamedInstrProfRecord &&Other,
InstrProfRecord &Dest = Where->second;
uint64_t ValueCutoff = FuncFilter.ValueCutoff;
- if (!FuncFilter.NameFilter.empty() &&
- Name.find(FuncFilter.NameFilter) != Name.npos)
+ if (!FuncFilter.NameFilter.empty() && Name.contains(FuncFilter.NameFilter))
ValueCutoff = 0;
Dest.overlap(Other, Overlap, FuncLevelOverlap, ValueCutoff);
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 36a0b6f6436bd..790fd3ef3376f 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -240,7 +240,7 @@ std::error_code SampleProfileWriterExtBinaryBase::writeNameTableSection(
// so compiler won't strip the suffix during profile matching after
// seeing the flag in the profile.
for (const auto &I : NameTable) {
- if (I.first.find(FunctionSamples::UniqSuffix) != StringRef::npos) {
+ if (I.first.contains(FunctionSamples::UniqSuffix)) {
addSectionFlag(SecNameTable, SecNameTableFlags::SecFlagUniqSuffix);
break;
}
diff --git a/llvm/lib/Support/ARMTargetParser.cpp b/llvm/lib/Support/ARMTargetParser.cpp
index 842f7471429b7..4405ed176fe23 100644
--- a/llvm/lib/Support/ARMTargetParser.cpp
+++ b/llvm/lib/Support/ARMTargetParser.cpp
@@ -307,7 +307,7 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
else if (A.startswith("aarch64")) {
offset = 7;
// AArch64 uses "_be", not "eb" suffix.
- if (A.find("eb") != StringRef::npos)
+ if (A.contains("eb"))
return Error;
if (A.substr(offset, 3) == "_be")
offset += 3;
@@ -333,7 +333,7 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
if (A.size() >= 2 && (A[0] != 'v' || !std::isdigit(A[1])))
return Error;
// Can't have an extra 'eb'.
- if (A.find("eb") != StringRef::npos)
+ if (A.contains("eb"))
return Error;
}
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index be59bb0232def..089342030b97e 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -71,7 +71,8 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
assert(!Name.empty() && "Must have a name!");
// Use the given path verbatim if it contains any slashes; this matches
// the behavior of sh(1) and friends.
- if (Name.find('/') != StringRef::npos) return std::string(Name);
+ if (Name.contains('/'))
+ return std::string(Name);
SmallVector<StringRef, 16> EnvironmentPaths;
if (Paths.empty())
More information about the llvm-commits
mailing list