[clang] dccfadd - [clang] Use StringRef::contains (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 21 08:58:32 PDT 2021
Author: Kazu Hirata
Date: 2021-10-21T08:58:19-07:00
New Revision: dccfaddc6bcc711bd972b43bff5ce6d71c1b39dc
URL: https://github.com/llvm/llvm-project/commit/dccfaddc6bcc711bd972b43bff5ce6d71c1b39dc
DIFF: https://github.com/llvm/llvm-project/commit/dccfaddc6bcc711bd972b43bff5ce6d71c1b39dc.diff
LOG: [clang] Use StringRef::contains (NFC)
Added:
Modified:
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
clang/lib/ARCMigrate/Transforms.cpp
clang/lib/AST/Expr.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/LiteralSupport.cpp
clang/lib/Rewrite/Rewriter.cpp
clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
clang/utils/TableGen/NeonEmitter.cpp
clang/utils/TableGen/RISCVVEmitter.cpp
Removed:
################################################################################
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index c8a389d1f2e5a..e99c6435062fb 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -487,9 +487,8 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
// Short circuit 'delegate' properties that contain the name "delegate" or
// "dataSource", or have exact name "target" to have 'assign' attribute.
- if (PropertyName.equals("target") ||
- (PropertyName.find("delegate") != StringRef::npos) ||
- (PropertyName.find("dataSource") != StringRef::npos)) {
+ if (PropertyName.equals("target") || PropertyName.contains("delegate") ||
+ PropertyName.contains("dataSource")) {
QualType QT = Getter->getReturnType();
if (!QT->isRealType())
append_attr(PropertyString, "assign", LParenAdded);
diff --git a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
index b14364509a0bf..40220a2eef491 100644
--- a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
+++ b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
@@ -146,9 +146,8 @@ class UnbridgedCastRewriter : public RecursiveASTVisitor<UnbridgedCastRewriter>{
ento::cocoa::isRefType(E->getSubExpr()->getType(), "CF",
FD->getIdentifier()->getName())) {
StringRef fname = FD->getIdentifier()->getName();
- if (fname.endswith("Retain") ||
- fname.find("Create") != StringRef::npos ||
- fname.find("Copy") != StringRef::npos) {
+ if (fname.endswith("Retain") || fname.contains("Create") ||
+ fname.contains("Copy")) {
// Do not migrate to couple of bridge transfer casts which
// cancel each other out. Leave it unchanged so error gets user
// attention instead.
@@ -168,7 +167,7 @@ class UnbridgedCastRewriter : public RecursiveASTVisitor<UnbridgedCastRewriter>{
return;
}
- if (fname.find("Get") != StringRef::npos) {
+ if (fname.contains("Get")) {
castToObjCObject(E, /*retained=*/false);
return;
}
diff --git a/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp
index e274a540e4083..ca48160d9c856 100644
--- a/clang/lib/ARCMigrate/Transforms.cpp
+++ b/clang/lib/ARCMigrate/Transforms.cpp
@@ -95,11 +95,9 @@ bool trans::isPlusOne(const Expr *E) {
ento::cocoa::isRefType(callE->getType(), "CF",
FD->getIdentifier()->getName())) {
StringRef fname = FD->getIdentifier()->getName();
- if (fname.endswith("Retain") ||
- fname.find("Create") != StringRef::npos ||
- fname.find("Copy") != StringRef::npos) {
+ if (fname.endswith("Retain") || fname.contains("Create") ||
+ fname.contains("Copy"))
return true;
- }
}
}
}
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f0c195c08ccba..e9ee624e499da 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4116,7 +4116,7 @@ bool ExtVectorElementExpr::containsDuplicateElements() const {
Comp = Comp.substr(1);
for (unsigned i = 0, e = Comp.size(); i != e; ++i)
- if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
+ if (Comp.substr(i + 1).contains(Comp[i]))
return true;
return false;
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 12e3c488d61a3..b7622e3b51f1e 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -468,8 +468,8 @@ hasAnyOverloadedOperatorNameFunc(ArrayRef<const StringRef *> NameRefs) {
}
HasNameMatcher::HasNameMatcher(std::vector<std::string> N)
- : UseUnqualifiedMatch(llvm::all_of(
- N, [](StringRef Name) { return Name.find("::") == Name.npos; })),
+ : UseUnqualifiedMatch(
+ llvm::all_of(N, [](StringRef Name) { return !Name.contains("::"); })),
Names(std::move(N)) {
#ifndef NDEBUG
for (StringRef Name : Names)
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 7ed1e40333f43..1d7b968e994f5 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -397,8 +397,7 @@ const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
ArgEffect(DoNothing), ArgEffect(DoNothing));
} else if (FName.startswith("NSLog")) {
return getDoNothingSummary();
- } else if (FName.startswith("NS") &&
- (FName.find("Insert") != StringRef::npos)) {
+ } else if (FName.startswith("NS") && FName.contains("Insert")) {
// Whitelist NSXXInsertXX, for example NSMapInsertIfAbsent, since they can
// be deallocated by NSMapRemove. (radar://11152419)
ScratchArgs = AF.add(ScratchArgs, 1, ArgEffect(StopTracking));
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0b336d410a07e..fc4540f26aabc 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2500,8 +2500,7 @@ void CodeGenFunction::checkTargetFeatures(SourceLocation Loc,
// Return if the builtin doesn't have any required features.
if (FeatureList.empty())
return;
- assert(FeatureList.find(' ') == StringRef::npos &&
- "Space in feature list");
+ assert(!FeatureList.contains(' ') && "Space in feature list");
TargetFeatures TF(CallerFeatureMap);
if (!TF.hasRequiredFeatures(FeatureList))
CGM.getDiags().Report(Loc, diag::err_builtin_needs_feature)
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 10951a01150a8..c76346337dc99 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -2646,7 +2646,7 @@ static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
// If the argument does not end in .lib, automatically add the suffix.
// If the argument contains a space, enclose it in quotes.
// This matches the behavior of MSVC.
- bool Quote = (Lib.find(' ') != StringRef::npos);
+ bool Quote = Lib.contains(' ');
std::string ArgStr = Quote ? "\"" : "";
ArgStr += Lib;
if (!Lib.endswith_insensitive(".lib") && !Lib.endswith_insensitive(".a"))
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 866ebb193a546..150e7edb12c18 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1037,7 +1037,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
// resolve "foo.h" any other way, change the include to <Foo/foo.h>, where
// "Foo" is the name of the framework in which the including header was found.
if (!Includers.empty() && Includers.front().first && !isAngled &&
- Filename.find('/') == StringRef::npos) {
+ !Filename.contains('/')) {
HeaderFileInfo &IncludingHFI = getFileInfo(Includers.front().first);
if (IncludingHFI.IndexHeaderMapHeader) {
SmallString<128> ScratchFilename;
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 64fad46323cbc..a8022812a3636 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1242,7 +1242,7 @@ NumericLiteralParser::GetFloatValue(llvm::APFloat &Result) {
llvm::SmallString<16> Buffer;
StringRef Str(ThisTokBegin, n);
- if (Str.find('\'') != StringRef::npos) {
+ if (Str.contains('\'')) {
Buffer.reserve(n);
std::remove_copy_if(Str.begin(), Str.end(), std::back_inserter(Buffer),
&isDigitSeparator);
diff --git a/clang/lib/Rewrite/Rewriter.cpp b/clang/lib/Rewrite/Rewriter.cpp
index 040e1c284253c..3b06afc76e16e 100644
--- a/clang/lib/Rewrite/Rewriter.cpp
+++ b/clang/lib/Rewrite/Rewriter.cpp
@@ -259,7 +259,7 @@ bool Rewriter::InsertText(SourceLocation Loc, StringRef Str,
unsigned StartOffs = getLocationOffsetAndFileID(Loc, FID);
SmallString<128> indentedStr;
- if (indentNewLines && Str.find('\n') != StringRef::npos) {
+ if (indentNewLines && Str.contains('\n')) {
StringRef MB = SourceMgr->getBufferData(FID);
unsigned lineNo = SourceMgr->getLineNumber(FID, StartOffs) - 1;
diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index caced02e1e110..c3735f70136dd 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -455,7 +455,7 @@ void ASTPropsEmitter::emitPropertiedReaderWriterBody(HasProperties node,
// Emit code to read all the properties.
visitAllProperties(node, nodeInfo, [&](Property prop) {
// Verify that the creation code refers to this property.
- if (info.IsReader && creationCode.find(prop.getName()) == StringRef::npos)
+ if (info.IsReader && !creationCode.contains(prop.getName()))
PrintFatalError(nodeInfo.Creator.getLoc(),
"creation code for " + node.getName()
+ " doesn't refer to property \""
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index f0da1a7d2f4ee..2945849382958 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -382,7 +382,7 @@ class Intrinsic {
StringRef Mods = getNextModifiers(Proto, Pos);
while (!Mods.empty()) {
Types.emplace_back(InTS, Mods);
- if (Mods.find('!') != StringRef::npos)
+ if (Mods.contains('!'))
PolymorphicKeyType = Types.size() - 1;
Mods = getNextModifiers(Proto, Pos);
diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp
index b4fa0e2884705..26aecb6fd961e 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -652,7 +652,7 @@ void RVVType::applyModifier(StringRef Transformer) {
assert(Idx != StringRef::npos);
StringRef ComplexType = Transformer.slice(1, Idx);
Transformer = Transformer.drop_front(Idx + 1);
- assert(Transformer.find('(') == StringRef::npos &&
+ assert(!Transformer.contains('(') &&
"Only allow one complex type transformer");
auto UpdateAndCheckComplexProto = [&]() {
More information about the cfe-commits
mailing list