Skip to content

Commit 5b83bd1

Browse files
[llvm] Use StringRef::contains (NFC)
1 parent cfbf0a5 commit 5b83bd1

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

llvm/lib/AsmParser/LLLexer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ lltok::Kind LLLexer::LexDollar() {
279279
if (CurChar == '"') {
280280
StrVal.assign(TokStart + 2, CurPtr - 1);
281281
UnEscapeLexed(StrVal);
282-
if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
282+
if (StringRef(StrVal).contains(0)) {
283283
Error("Null bytes are not allowed in names");
284284
return lltok::Error;
285285
}
@@ -362,7 +362,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
362362
if (CurChar == '"') {
363363
StrVal.assign(TokStart+2, CurPtr-1);
364364
UnEscapeLexed(StrVal);
365-
if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
365+
if (StringRef(StrVal).contains(0)) {
366366
Error("Null bytes are not allowed in names");
367367
return lltok::Error;
368368
}
@@ -397,7 +397,7 @@ lltok::Kind LLLexer::LexQuote() {
397397

398398
if (CurPtr[0] == ':') {
399399
++CurPtr;
400-
if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
400+
if (StringRef(StrVal).contains(0)) {
401401
Error("Null bytes are not allowed in names");
402402
kind = lltok::Error;
403403
} else {

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ Expected<Value *> BitcodeReader::recordValue(SmallVectorImpl<uint64_t> &Record,
26462646
Value *V = ValueList[ValueID];
26472647

26482648
StringRef NameStr(ValueName.data(), ValueName.size());
2649-
if (NameStr.find_first_of(0) != StringRef::npos)
2649+
if (NameStr.contains(0))
26502650
return error("Invalid value name");
26512651
V->setName(NameStr);
26522652
auto *GO = dyn_cast<GlobalObject>(V);

llvm/lib/IR/Value.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ void Value::setNameImpl(const Twine &NewName) {
330330

331331
SmallString<256> NameData;
332332
StringRef NameRef = NeedNewName ? NewName.toStringRef(NameData) : "";
333-
assert(NameRef.find_first_of(0) == StringRef::npos &&
334-
"Null bytes are not allowed in names");
333+
assert(!NameRef.contains(0) && "Null bytes are not allowed in names");
335334

336335
// Name isn't changing?
337336
if (getName() == NameRef)

0 commit comments

Comments
 (0)