diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index c8a389d1f2e5..e99c6435062f 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 b14364509a0b..40220a2eef49 100644 --- a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp +++ b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp @@ -146,9 +146,8 @@ private: 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 @@ private: 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 e274a540e408..ca48160d9c85 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 f0c195c08ccb..e9ee624e499d 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 12e3c488d61a..b7622e3b51f1 100644 --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -468,8 +468,8 @@ hasAnyOverloadedOperatorNameFunc(ArrayRef NameRefs) { } HasNameMatcher::HasNameMatcher(std::vector 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 7ed1e40333f4..1d7b968e994f 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 0b336d410a07..fc4540f26aab 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 10951a01150a..c76346337dc9 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 866ebb193a54..150e7edb12c1 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1037,7 +1037,7 @@ Optional HeaderSearch::LookupFile( // resolve "foo.h" any other way, change the include to , 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 64fad46323cb..a8022812a363 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 040e1c284253..3b06afc76e16 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 caced02e1e11..c3735f70136d 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 f0da1a7d2f4e..294584938295 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -382,7 +382,7 @@ public: 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 b4fa0e288470..26aecb6fd961 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 = [&]() {