mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-18 16:58:23 +00:00
[clang] Use StringRef::contains (NFC)
This commit is contained in:
parent
f6811cec84
commit
dccfaddc6b
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
|
@ -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)
|
||||
|
@ -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"))
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 \""
|
||||
|
@ -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);
|
||||
|
@ -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 = [&]() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user