[Mlir-commits] [mlir] 88d319a - [mlir] Use StringRef::{starts, ends}_with (NFC)
Kazu Hirata
llvmlistbot at llvm.org
Wed Dec 13 22:58:37 PST 2023
Author: Kazu Hirata
Date: 2023-12-13T22:58:30-08:00
New Revision: 88d319a29ff5d3be1bb9a7e88ef6e17df1dfe607
URL: https://github.com/llvm/llvm-project/commit/88d319a29ff5d3be1bb9a7e88ef6e17df1dfe607
DIFF: https://github.com/llvm/llvm-project/commit/88d319a29ff5d3be1bb9a7e88ef6e17df1dfe607.diff
LOG: [mlir] Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.
I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
Added:
Modified:
mlir/lib/AsmParser/AttributeParser.cpp
mlir/lib/AsmParser/Parser.cpp
mlir/lib/Bytecode/Reader/BytecodeReader.cpp
mlir/lib/Dialect/AMDGPU/Utils/Chipset.cpp
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/Query/Matcher/Parser.cpp
mlir/lib/Support/ToolUtilities.cpp
mlir/lib/TableGen/Class.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
mlir/lib/Tools/PDLL/Parser/Parser.cpp
mlir/lib/Tools/lsp-server-support/Protocol.cpp
mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
mlir/lib/Tools/lsp-server-support/Transport.cpp
mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp
mlir/tools/mlir-parser-fuzzer/bytecode/mlir-bytecode-parser-fuzzer.cpp
mlir/tools/mlir-parser-fuzzer/text/mlir-text-parser-fuzzer.cpp
mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpDocGen.cpp
mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
Removed:
################################################################################
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index d085fb6af6bc14..efa65e49abc33b 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -660,7 +660,7 @@ TensorLiteralParser::getFloatAttrElements(SMLoc loc, FloatType eltTy,
const Token &token = signAndToken.second;
// Handle hexadecimal float literals.
- if (token.is(Token::integer) && token.getSpelling().startswith("0x")) {
+ if (token.is(Token::integer) && token.getSpelling().starts_with("0x")) {
std::optional<APFloat> result;
if (failed(p.parseFloatFromIntegerLiteral(result, token, isNegative,
eltTy.getFloatSemantics(),
diff --git a/mlir/lib/AsmParser/Parser.cpp b/mlir/lib/AsmParser/Parser.cpp
index 1fca85beb87fce..3aa9adcbe1c5df 100644
--- a/mlir/lib/AsmParser/Parser.cpp
+++ b/mlir/lib/AsmParser/Parser.cpp
@@ -2477,7 +2477,7 @@ class ParsedResourceEntry : public AsmParsedResourceEntry {
AsmResourceEntryKind getKind() const final {
if (value.isAny(Token::kw_true, Token::kw_false))
return AsmResourceEntryKind::Bool;
- return value.getSpelling().startswith("\"0x")
+ return value.getSpelling().starts_with("\"0x")
? AsmResourceEntryKind::Blob
: AsmResourceEntryKind::String;
}
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index 0bc2a2f676ba4b..7cf3bd83b925ca 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -2564,7 +2564,7 @@ BytecodeReader::finalize(function_ref<bool(Operation *)> shouldMaterialize) {
}
bool mlir::isBytecode(llvm::MemoryBufferRef buffer) {
- return buffer.getBuffer().startswith("ML\xefR");
+ return buffer.getBuffer().starts_with("ML\xefR");
}
/// Read the bytecode from the provided memory buffer reference.
diff --git a/mlir/lib/Dialect/AMDGPU/Utils/Chipset.cpp b/mlir/lib/Dialect/AMDGPU/Utils/Chipset.cpp
index 4f075c71c947d1..2540e1fb86d87d 100644
--- a/mlir/lib/Dialect/AMDGPU/Utils/Chipset.cpp
+++ b/mlir/lib/Dialect/AMDGPU/Utils/Chipset.cpp
@@ -14,7 +14,7 @@ using namespace mlir;
using namespace mlir::amdgpu;
FailureOr<Chipset> Chipset::parse(StringRef name) {
- if (!name.startswith("gfx"))
+ if (!name.starts_with("gfx"))
return failure();
unsigned major = 0;
unsigned minor = 0;
diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
index f0c294c22695b5..5cce7befce5283 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -201,9 +201,9 @@ SerializeToHsacoPass::translateToLLVMIR(llvm::LLVMContext &llvmContext) {
StringRef funcName = f.getName();
if ("printf" == funcName)
needOpenCl = true;
- if (funcName.startswith("__ockl_"))
+ if (funcName.starts_with("__ockl_"))
needOckl = true;
- if (funcName.startswith("__ocml_"))
+ if (funcName.starts_with("__ocml_"))
needOcml = true;
}
}
@@ -253,7 +253,7 @@ SerializeToHsacoPass::translateToLLVMIR(llvm::LLVMContext &llvmContext) {
if (needOcml || needOckl) {
addControlConstant("__oclc_wavefrontsize64", 1, 8);
StringRef chipSet = this->chip.getValue();
- if (chipSet.startswith("gfx"))
+ if (chipSet.starts_with("gfx"))
chipSet = chipSet.substr(3);
uint32_t minor =
llvm::APInt(32, chipSet.substr(chipSet.size() - 2), 16).getZExtValue();
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 53e1088f620d7e..458bf83eac17f8 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2916,7 +2916,7 @@ OpFoldResult LLVM::OrOp::fold(FoldAdaptor adaptor) {
//===----------------------------------------------------------------------===//
LogicalResult CallIntrinsicOp::verify() {
- if (!getIntrin().startswith("llvm."))
+ if (!getIntrin().starts_with("llvm."))
return emitOpError() << "intrinsic name must start with 'llvm.'";
return success();
}
diff --git a/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp b/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp
index c92472acf27948..3fa26bce150992 100644
--- a/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp
+++ b/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp
@@ -69,7 +69,7 @@ LogicalResult transform::detail::expandPathsToMLIRFiles(
continue;
}
- if (!StringRef(fileName).endswith(".mlir")) {
+ if (!StringRef(fileName).ends_with(".mlir")) {
LLVM_DEBUG(DBGS() << " Skipping '" << fileName
<< "' because it does not end with '.mlir'\n");
continue;
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 7507e0cd0c99b3..87be08712ea35b 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -751,7 +751,7 @@ void OpState::print(Operation *op, OpAsmPrinter &p, StringRef defaultDialect) {
void OpState::printOpName(Operation *op, OpAsmPrinter &p,
StringRef defaultDialect) {
StringRef name = op->getName().getStringRef();
- if (name.startswith((defaultDialect + ".").str()) && name.count('.') == 1)
+ if (name.starts_with((defaultDialect + ".").str()) && name.count('.') == 1)
name = name.drop_front(defaultDialect.size() + 1);
p.getStream() << name;
}
diff --git a/mlir/lib/Query/Matcher/Parser.cpp b/mlir/lib/Query/Matcher/Parser.cpp
index be9e60de221db1..6585b5d740f626 100644
--- a/mlir/lib/Query/Matcher/Parser.cpp
+++ b/mlir/lib/Query/Matcher/Parser.cpp
@@ -384,7 +384,7 @@ bool Parser::parseMatcherExpressionImpl(const TokenInfo &nameToken,
// completions minus the prefix.
void Parser::addCompletion(const TokenInfo &compToken,
const MatcherCompletion &completion) {
- if (llvm::StringRef(completion.typedText).startswith(compToken.text)) {
+ if (llvm::StringRef(completion.typedText).starts_with(compToken.text)) {
completions.emplace_back(completion.typedText.substr(compToken.text.size()),
completion.matcherDecl);
}
diff --git a/mlir/lib/Support/ToolUtilities.cpp b/mlir/lib/Support/ToolUtilities.cpp
index 0f9c4a933d008b..ee0214f3d8ac04 100644
--- a/mlir/lib/Support/ToolUtilities.cpp
+++ b/mlir/lib/Support/ToolUtilities.cpp
@@ -58,7 +58,7 @@ mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer> originalBuffer,
}
// Check that suffix is as expected and doesn't have any dash post.
- bool expectedSuffix = buffer.startswith(splitMarker.take_back(checkLen)) &&
+ bool expectedSuffix = buffer.starts_with(splitMarker.take_back(checkLen)) &&
buffer.size() > checkLen && buffer[checkLen] != '0';
if (expectedSuffix) {
sourceBuffers.push_back(prev);
diff --git a/mlir/lib/TableGen/Class.cpp b/mlir/lib/TableGen/Class.cpp
index 36038230568501..f71d7e07ed4998 100644
--- a/mlir/lib/TableGen/Class.cpp
+++ b/mlir/lib/TableGen/Class.cpp
@@ -18,7 +18,8 @@ using namespace mlir::tblgen;
/// Returns space to be emitted after the given C++ `type`. return "" if the
/// ends with '&' or '*', or is empty, else returns " ".
static StringRef getSpaceAfterType(StringRef type) {
- return (type.empty() || type.endswith("&") || type.endswith("*")) ? "" : " ";
+ return (type.empty() || type.ends_with("&") || type.ends_with("*")) ? ""
+ : " ";
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 3dd082aae19338..9f0e1f3c3bb6f6 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -161,7 +161,7 @@ translateDataLayout(DataLayoutSpecInterface attribute,
}
layoutStream.flush();
StringRef layoutSpec(llvmDataLayout);
- if (layoutSpec.startswith("-"))
+ if (layoutSpec.starts_with("-"))
layoutSpec = layoutSpec.drop_front();
return llvm::DataLayout(layoutSpec);
diff --git a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
index 7510e1e2eb9b6f..954aaa98c32998 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
@@ -354,7 +354,7 @@ Deserializer::processOp<spirv::EntryPointOp>(ArrayRef<uint32_t> words) {
// The deserializer uses "spirv_fn_<id>" as the function name if the input
// SPIR-V blob does not contain a name for it. We should use a more clear
// indication for such case rather than relying on naming details.
- if (!parsedFunc.getName().startswith("spirv_fn_"))
+ if (!parsedFunc.getName().starts_with("spirv_fn_"))
return emitError(unknownLoc,
"function name mismatch between OpEntryPoint "
"and OpFunction with <id> ")
diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index 93eb5e892e228e..cfbc4e4536fe8c 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -792,7 +792,7 @@ LogicalResult Parser::parseInclude(SmallVectorImpl<ast::Decl *> &decls) {
// Check the type of include. If ending with `.pdll`, this is another pdl file
// to be parsed along with the current module.
- if (filename.endswith(".pdll")) {
+ if (filename.ends_with(".pdll")) {
if (failed(lexer.pushInclude(filename, fileLoc)))
return emitError(fileLoc,
"unable to open include file `" + filename + "`");
@@ -807,7 +807,7 @@ LogicalResult Parser::parseInclude(SmallVectorImpl<ast::Decl *> &decls) {
}
// Otherwise, this must be a `.td` include.
- if (filename.endswith(".td"))
+ if (filename.ends_with(".td"))
return parseTdInclude(filename, fileLoc, decls);
return emitError(fileLoc,
diff --git a/mlir/lib/Tools/lsp-server-support/Protocol.cpp b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
index 6d8cec6a54d1a4..e110fdd97a38f1 100644
--- a/mlir/lib/Tools/lsp-server-support/Protocol.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
@@ -157,7 +157,7 @@ static llvm::Expected<std::string> uriFromAbsolutePath(StringRef absolutePath,
// If authority if empty, we only print body if it starts with "/"; otherwise,
// the URI is invalid.
- if (!authority.empty() || StringRef(body).startswith("/")) {
+ if (!authority.empty() || StringRef(body).starts_with("/")) {
uri.append("//");
percentEncode(authority, uri);
}
@@ -167,7 +167,7 @@ static llvm::Expected<std::string> uriFromAbsolutePath(StringRef absolutePath,
static llvm::Expected<std::string> getAbsolutePath(StringRef authority,
StringRef body) {
- if (!body.startswith("/"))
+ if (!body.starts_with("/"))
return llvm::createStringError(
llvm::inconvertibleErrorCode(),
"File scheme: expect body to be an absolute path starting "
diff --git a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
index b6f4f3cc1869ed..f8d348aba5a3cc 100644
--- a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
+++ b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
@@ -99,7 +99,7 @@ lsp::extractSourceDocComment(llvm::SourceMgr &sourceMgr, SMLoc loc) {
SmallVector<StringRef> commentLines;
while (std::optional<StringRef> line = popLastLine()) {
// Check for a comment at the beginning of the line.
- if (!line->startswith("//"))
+ if (!line->starts_with("//"))
break;
// Extract the document string from the comment.
diff --git a/mlir/lib/Tools/lsp-server-support/Transport.cpp b/mlir/lib/Tools/lsp-server-support/Transport.cpp
index 3915146f6a66d1..df675cf78210be 100644
--- a/mlir/lib/Tools/lsp-server-support/Transport.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Transport.cpp
@@ -345,7 +345,7 @@ LogicalResult JSONTransport::readDelimitedMessage(std::string &json) {
llvm::SmallString<128> line;
while (succeeded(readLine(in, line))) {
StringRef lineRef = line.str().trim();
- if (lineRef.startswith("//")) {
+ if (lineRef.starts_with("//")) {
// Found a delimiter for the message.
if (lineRef == "// -----")
break;
diff --git a/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp b/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
index d272164b1d2677..0f23366f6fe80a 100644
--- a/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
@@ -253,7 +253,8 @@ void LSPServer::onCodeAction(const CodeActionParams ¶ms,
if (only.empty())
return true;
return llvm::any_of(only, [&](StringRef base) {
- return kind.consume_front(base) && (kind.empty() || kind.startswith("."));
+ return kind.consume_front(base) &&
+ (kind.empty() || kind.starts_with("."));
});
};
diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
index 9850c972560759..de657a3df9ef7b 100644
--- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
@@ -181,7 +181,7 @@ static unsigned getBlockNumber(Block *block) {
static void printDefBlockName(raw_ostream &os, Block *block, SMRange loc = {}) {
// Try to extract a name from the source location.
std::optional<StringRef> text = getTextFromRange(loc);
- if (text && text->startswith("^")) {
+ if (text && text->starts_with("^")) {
os << *text;
return;
}
@@ -900,7 +900,7 @@ void MLIRDocument::getCodeActionForDiagnostic(
// Ignore diagnostics that print the current operation. These are always
// enabled for the language server, but not generally during normal
// parsing/verification.
- if (message.startswith("see current operation: "))
+ if (message.starts_with("see current operation: "))
return;
// Get the start of the line containing the diagnostic.
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index 8efc6147673173..a5c6c2bb2c6a0c 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -946,7 +946,7 @@ class LSPCodeCompleteContext : public CodeCompleteContext {
break;
case llvm::sys::fs::file_type::regular_file: {
// Only consider concrete files that can actually be included by PDLL.
- if (filename.endswith(".pdll") || filename.endswith(".td"))
+ if (filename.ends_with(".pdll") || filename.ends_with(".td"))
addIncludeCompletion(filename, /*isDirectory=*/false);
break;
}
diff --git a/mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp b/mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp
index 8f0c13af9de5bf..a6678995fc6f67 100644
--- a/mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp
+++ b/mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp
@@ -48,7 +48,7 @@ struct TestEmulateWideIntPass
}
func::FuncOp op = getOperation();
- if (!op.getSymName().startswith(testFunctionPrefix))
+ if (!op.getSymName().starts_with(testFunctionPrefix))
return;
MLIRContext *ctx = op.getContext();
diff --git a/mlir/tools/mlir-parser-fuzzer/bytecode/mlir-bytecode-parser-fuzzer.cpp b/mlir/tools/mlir-parser-fuzzer/bytecode/mlir-bytecode-parser-fuzzer.cpp
index 21411b684c15af..bb06c64d7215ac 100644
--- a/mlir/tools/mlir-parser-fuzzer/bytecode/mlir-bytecode-parser-fuzzer.cpp
+++ b/mlir/tools/mlir-parser-fuzzer/bytecode/mlir-bytecode-parser-fuzzer.cpp
@@ -26,7 +26,7 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerTestOneInput(const uint8_t *data,
return -1;
llvm::StringRef str(reinterpret_cast<const char *>(data), size - 1);
// Skip if not bytecode.
- if (!str.startswith("ML\xefR"))
+ if (!str.starts_with("ML\xefR"))
return -1;
// Create a null-terminated memory buffer from the input.
diff --git a/mlir/tools/mlir-parser-fuzzer/text/mlir-text-parser-fuzzer.cpp b/mlir/tools/mlir-parser-fuzzer/text/mlir-text-parser-fuzzer.cpp
index 5555c039eae9a2..faa578bc1fde89 100644
--- a/mlir/tools/mlir-parser-fuzzer/text/mlir-text-parser-fuzzer.cpp
+++ b/mlir/tools/mlir-parser-fuzzer/text/mlir-text-parser-fuzzer.cpp
@@ -26,7 +26,7 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerTestOneInput(const uint8_t *data,
return -1;
llvm::StringRef str(reinterpret_cast<const char *>(data), size - 1);
// Skip if bytecode.
- if (str.startswith("ML\xefR"))
+ if (str.starts_with("ML\xefR"))
return -1;
// Create a null-terminated memory buffer from the input.
diff --git a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
index f627d2dd3ea084..00665f93c8a51e 100644
--- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
+++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
@@ -98,7 +98,7 @@ class LLVMIntrinsic {
return name.str();
name = record.getName();
- assert(name.startswith("int_") &&
+ assert(name.starts_with("int_") &&
"LLVM intrinsic names are expected to start with 'int_'");
name = name.drop_front(4);
llvm::SmallVector<llvm::StringRef, 8> chunks;
@@ -121,7 +121,7 @@ class LLVMIntrinsic {
/// Get the name of the record without the "intrinsic" prefix.
llvm::StringRef getProperRecordName() const {
llvm::StringRef name = record.getName();
- assert(name.startswith("int_") &&
+ assert(name.starts_with("int_") &&
"LLVM intrinsic names are expected to start with 'int_'");
return name.drop_front(4);
}
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 57392434285ff8..cd37c8dcd3d5e0 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1960,7 +1960,7 @@ static std::string generateTypeForGetter(const NamedTypeConstraint &value) {
/// Adaptor will have values that are not from the type of their operation and
/// this is expected, so we dont generate TypedValue for Adaptor
if (value.constraint.getCPPClassName() != "::mlir::Type" &&
- StringRef(value.constraint.getCPPClassName()).startswith("::"))
+ StringRef(value.constraint.getCPPClassName()).starts_with("::"))
str = llvm::formatv("::mlir::TypedValue<{0}>",
value.constraint.getCPPClassName())
.str();
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index b5b26a70859ece..877ef1089dcec0 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -79,7 +79,7 @@ void mlir::tblgen::emitDescriptionComment(StringRef description,
raw_indented_ostream ros(os);
StringRef trimmed = description.rtrim(" \t");
ros.printReindented(trimmed, (Twine(prefix) + "/// ").str());
- if (!trimmed.endswith("\n"))
+ if (!trimmed.ends_with("\n"))
ros << "\n";
}
@@ -137,7 +137,7 @@ static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) {
StringRef traitName = trait.getDef().getValueAsString("trait");
traitName.consume_back("::Trait");
traitName.consume_back("::Impl");
- if (ref.startswith("anonymous_"))
+ if (ref.starts_with("anonymous_"))
name = traitName.str();
if (isa<InterfaceTrait>(&trait)) {
if (trait.getDef().isSubClassOf("SideEffectsTraitBase")) {
diff --git a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
index 0c0ad2cfeffdcc..0770ed562309e7 100644
--- a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
@@ -295,7 +295,7 @@ static bool isODSReserved(StringRef str) {
{"attributes", "create", "context", "ip", "operands", "print", "get_asm",
"loc", "verify", "regions", "results", "self", "operation",
"DIALECT_NAMESPACE", "OPERATION_NAME"});
- return str.startswith("_ods_") || str.endswith("_ods") ||
+ return str.starts_with("_ods_") || str.ends_with("_ods") ||
reserved.contains(str);
}
More information about the Mlir-commits
mailing list