aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MIRParser/MIParser.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-08-25 11:30:49 -0700
committerGitHub <noreply@github.com>2024-08-25 11:30:49 -0700
commit33e7cd6ff23f6c904314d17c68dc58168fd32d09 (patch)
tree544969f067771e290d1c729ab896219dc1da135e /llvm/lib/CodeGen/MIRParser/MIParser.cpp
parent33f3ebc86e7d3afcb65c551feba5bbc2421b42ed (diff)
downloadllvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.zip
llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.tar.gz
llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.tar.bz2
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)
S.substr(N) is simpler than S.slice(N, StringRef::npos) and S.slice(N, S.size()). Also, substr is probably better recognizable than slice thanks to std::string_view::substr.
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MIParser.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 0e2b717..47b2201 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -580,7 +580,7 @@ MIParser::MIParser(PerFunctionMIParsingState &PFS, SMDiagnostic &Error,
void MIParser::lex(unsigned SkipChar) {
CurrentSource = lexMIToken(
- CurrentSource.slice(SkipChar, StringRef::npos), Token,
+ CurrentSource.substr(SkipChar), Token,
[this](StringRef::iterator Loc, const Twine &Msg) { error(Loc, Msg); });
}
@@ -2306,7 +2306,7 @@ bool MIParser::parseDIExpression(MDNode *&Expr) {
Expr = llvm::parseDIExpressionBodyAtBeginning(
CurrentSource, Read, Error, *PFS.MF.getFunction().getParent(),
&PFS.IRSlots);
- CurrentSource = CurrentSource.slice(Read, StringRef::npos);
+ CurrentSource = CurrentSource.substr(Read);
lex();
if (!Expr)
return error(Error.getMessage());