[llvm] 5b83bd1 - [llvm] Use StringRef::contains (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 17:29:10 PDT 2023
Author: Kazu Hirata
Date: 2023-10-18T17:29:04-07:00
New Revision: 5b83bd133d705b024bfb34e4941941689456ba8c
URL: https://github.com/llvm/llvm-project/commit/5b83bd133d705b024bfb34e4941941689456ba8c
DIFF: https://github.com/llvm/llvm-project/commit/5b83bd133d705b024bfb34e4941941689456ba8c.diff
LOG: [llvm] Use StringRef::contains (NFC)
Added:
Modified:
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/IR/Value.cpp
Removed:
################################################################################
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index 1402c152bb5c313..ae46209b30ede03 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -279,7 +279,7 @@ lltok::Kind LLLexer::LexDollar() {
if (CurChar == '"') {
StrVal.assign(TokStart + 2, CurPtr - 1);
UnEscapeLexed(StrVal);
- if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
+ if (StringRef(StrVal).contains(0)) {
Error("Null bytes are not allowed in names");
return lltok::Error;
}
@@ -362,7 +362,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
if (CurChar == '"') {
StrVal.assign(TokStart+2, CurPtr-1);
UnEscapeLexed(StrVal);
- if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
+ if (StringRef(StrVal).contains(0)) {
Error("Null bytes are not allowed in names");
return lltok::Error;
}
@@ -397,7 +397,7 @@ lltok::Kind LLLexer::LexQuote() {
if (CurPtr[0] == ':') {
++CurPtr;
- if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
+ if (StringRef(StrVal).contains(0)) {
Error("Null bytes are not allowed in names");
kind = lltok::Error;
} else {
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 16eafa6e18f5d59..28addb9068b242b 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2646,7 +2646,7 @@ Expected<Value *> BitcodeReader::recordValue(SmallVectorImpl<uint64_t> &Record,
Value *V = ValueList[ValueID];
StringRef NameStr(ValueName.data(), ValueName.size());
- if (NameStr.find_first_of(0) != StringRef::npos)
+ if (NameStr.contains(0))
return error("Invalid value name");
V->setName(NameStr);
auto *GO = dyn_cast<GlobalObject>(V);
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 41260a98e3ce768..b485a6275b4ded1 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -330,8 +330,7 @@ void Value::setNameImpl(const Twine &NewName) {
SmallString<256> NameData;
StringRef NameRef = NeedNewName ? NewName.toStringRef(NameData) : "";
- assert(NameRef.find_first_of(0) == StringRef::npos &&
- "Null bytes are not allowed in names");
+ assert(!NameRef.contains(0) && "Null bytes are not allowed in names");
// Name isn't changing?
if (getName() == NameRef)
More information about the llvm-commits
mailing list