Skip to content

Commit 20f0f15

Browse files
Use StringRef::contains (NFC)
1 parent 0e9d37f commit 20f0f15

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

bolt/include/bolt/Profile/DataReader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class DataReader : public ProfileReaderBase {
449449
bool usesEvent(StringRef Name) const {
450450
for (auto I = EventNames.begin(), E = EventNames.end(); I != E; ++I) {
451451
StringRef Event = I->getKey();
452-
if (Event.find(Name) != StringRef::npos)
452+
if (Event.contains(Name))
453453
return true;
454454
}
455455
return false;

bolt/lib/Profile/DataAggregator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ ErrorOr<DataAggregator::PerfMemSample> DataAggregator::parseMemSample() {
11581158
ErrorOr<StringRef> Event = parseString(FieldSeparator);
11591159
if (std::error_code EC = Event.getError())
11601160
return EC;
1161-
if (Event.get().find("mem-loads") == StringRef::npos) {
1161+
if (!Event.get().contains("mem-loads")) {
11621162
consumeRestOfLine();
11631163
return Res;
11641164
}

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
206206
llvm::StringRef NsName) {
207207
DeclName = DeclName.ltrim(':');
208208
NsName = NsName.ltrim(':');
209-
if (DeclName.find(':') == llvm::StringRef::npos)
209+
if (!DeclName.contains(':'))
210210
return std::string(DeclName);
211211

212212
auto NsNameSplitted = splitSymbolName(NsName);

clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
6868
PtrToContainer = true;
6969
}
7070
const llvm::StringRef IneffContName = IneffCont->getName();
71-
const bool Unordered =
72-
IneffContName.find("unordered") != llvm::StringRef::npos;
73-
const bool Maplike = IneffContName.find("map") != llvm::StringRef::npos;
71+
const bool Unordered = IneffContName.contains("unordered");
72+
const bool Maplike = IneffContName.contains("map");
7473

7574
// Store if the key type of the container is compatible with the value
7675
// that is searched for.
@@ -84,8 +83,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
8483
const Expr *Arg = AlgCall->getArg(3);
8584
const QualType AlgCmp =
8685
Arg->getType().getUnqualifiedType().getCanonicalType();
87-
const unsigned CmpPosition =
88-
(IneffContName.find("map") == llvm::StringRef::npos) ? 1 : 2;
86+
const unsigned CmpPosition = IneffContName.contains("map") ? 2 : 1;
8987
const QualType ContainerCmp = IneffCont->getTemplateArgs()[CmpPosition]
9088
.getAsType()
9189
.getUnqualifiedType()

flang/lib/Lower/ConvertExpr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ class ScalarExprLowering {
14971497
/// NaN strings as well. \p s is assumed to not contain any spaces.
14981498
static llvm::APFloat consAPFloat(const llvm::fltSemantics &fsem,
14991499
llvm::StringRef s) {
1500-
assert(s.find(' ') == llvm::StringRef::npos);
1500+
assert(!s.contains(' '));
15011501
if (s.compare_insensitive("-inf") == 0)
15021502
return llvm::APFloat::getInf(fsem, /*negative=*/true);
15031503
if (s.compare_insensitive("inf") == 0 || s.compare_insensitive("+inf") == 0)

flang/lib/Lower/IO.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,7 @@ lowerReferenceAsStringSelect(Fortran::lower::AbstractConverter &converter,
14171417
mlir::Value stringRef;
14181418
mlir::Value stringLen;
14191419
if (eval->isA<Fortran::parser::FormatStmt>()) {
1420-
assert(text.find('(') != llvm::StringRef::npos &&
1421-
"FORMAT is unexpectedly ill-formed");
1420+
assert(text.contains('(') && "FORMAT is unexpectedly ill-formed");
14221421
// This is a format statement, so extract the spec from the text.
14231422
std::tuple<mlir::Value, mlir::Value, mlir::Value> stringLit =
14241423
lowerSourceTextAsStringLit(converter, loc, text, strTy, lenTy);

0 commit comments

Comments
 (0)