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.
This commit is contained in:
@@ -451,7 +451,7 @@ std::unique_ptr<Logger> makeLogger(llvm::StringRef LogPrefix,
|
||||
void log(Level L, const char *Fmt,
|
||||
const llvm::formatv_object_base &Message) override {
|
||||
if (Context::current().get(CurrentRequest) == nullptr ||
|
||||
llvm::StringRef(Fmt).startswith("[public]"))
|
||||
llvm::StringRef(Fmt).starts_with("[public]"))
|
||||
return StreamLogger::log(L, Fmt, Message);
|
||||
if (L >= Error)
|
||||
return StreamLogger::log(L, Fmt,
|
||||
|
||||
@@ -99,7 +99,7 @@ using namespace clang;
|
||||
|
||||
AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
|
||||
llvm::StringRef AttrName = Name->getName();
|
||||
if (AttrName.startswith("__") && AttrName.endswith("__"))
|
||||
if (AttrName.starts_with("__") && AttrName.ends_with("__"))
|
||||
AttrName = AttrName.substr(2, AttrName.size() - 4);
|
||||
|
||||
return llvm::StringSwitch < AttributeList::Kind > (AttrName)
|
||||
|
||||
@@ -57,7 +57,7 @@ void Generator::parseCommandArgs(llvm::StringRef ArgStr, ArgVector &Args) {
|
||||
ArgStr.split(Args, ",");
|
||||
for (llvm::StringRef &A : Args) {
|
||||
A = A.trim(' ');
|
||||
if (A.startswith(ParamNamePrefix) && A.endswith(ParamNameSuffix)) {
|
||||
if (A.starts_with(ParamNamePrefix) && A.ends_with(ParamNameSuffix)) {
|
||||
A = A.drop_front(ParamNamePrefixSize).drop_back(ParamNameSuffixSize);
|
||||
A = ArgMap[std::string(A)];
|
||||
}
|
||||
@@ -80,7 +80,7 @@ void Generator::generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records) {
|
||||
Content = P.second;
|
||||
|
||||
llvm::StringRef Line = P.first.trim(' ');
|
||||
if (Line.startswith(CommandPrefix)) {
|
||||
if (Line.starts_with(CommandPrefix)) {
|
||||
Line = Line.drop_front(CommandPrefixSize);
|
||||
|
||||
P = Line.split("(");
|
||||
@@ -107,7 +107,7 @@ void Generator::generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records) {
|
||||
Command::ErrorReporter Reporter(
|
||||
llvm::SMLoc::getFromPointer(CommandName.data()), SrcMgr);
|
||||
Cmd->run(OS, Args, StdHeader, Records, Reporter);
|
||||
} else if (!Line.startswith(CommentPrefix)) {
|
||||
} else if (!Line.starts_with(CommentPrefix)) {
|
||||
// There is no comment or command on this line so we just write it as is.
|
||||
OS << P.first << "\n";
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ int dumpMLIR() {
|
||||
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
!llvm::StringRef(inputFilename).ends_with(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
|
||||
@@ -82,7 +82,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
!llvm::StringRef(inputFilename).ends_with(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
|
||||
@@ -83,7 +83,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
!llvm::StringRef(inputFilename).ends_with(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
|
||||
@@ -88,7 +88,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
!llvm::StringRef(inputFilename).ends_with(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
|
||||
@@ -112,7 +112,7 @@ int loadMLIR(mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
!llvm::StringRef(inputFilename).ends_with(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
|
||||
@@ -112,7 +112,7 @@ int loadMLIR(mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
!llvm::StringRef(inputFilename).ends_with(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
|
||||
@@ -290,7 +290,7 @@ struct GenericKernelTy {
|
||||
/// Return true if this kernel is a constructor or destructor.
|
||||
bool isCtorOrDtor() const {
|
||||
// TODO: This is not a great solution and should be revisited.
|
||||
return StringRef(Name).endswith("tor");
|
||||
return StringRef(Name).ends_with("tor");
|
||||
}
|
||||
|
||||
/// Get the kernel image.
|
||||
|
||||
@@ -1304,7 +1304,7 @@ struct CUDAPluginTy final : public GenericPluginTy {
|
||||
|
||||
StringRef ArchStr(Info->Arch);
|
||||
StringRef PrefixStr("sm_");
|
||||
if (!ArchStr.startswith(PrefixStr))
|
||||
if (!ArchStr.starts_with(PrefixStr))
|
||||
return Plugin::error("Unrecognized image arch %s", ArchStr.data());
|
||||
|
||||
int32_t ImageMajor = ArchStr[PrefixStr.size() + 0] - '0';
|
||||
|
||||
Reference in New Issue
Block a user