Skip to content

[llvm] Prefer StringRef::substr to StringRef::slice (NFC) #106330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/FileCheck/FileCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Pattern::parseVariable(StringRef &Str, const SourceMgr &SM) {
++I;

if (I == Str.size())
return ErrorDiagnostic::get(SM, Str.slice(I, StringRef::npos),
return ErrorDiagnostic::get(SM, Str.substr(I),
StringRef("empty ") +
(IsPseudo ? "pseudo " : "global ") +
"variable name");
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ static Expected<int64_t> parseChangeSectionLMA(StringRef ArgValue,
StringRef OptionName) {
StringRef StringValue;
if (ArgValue.starts_with("*+")) {
StringValue = ArgValue.slice(2, StringRef::npos);
StringValue = ArgValue.substr(2);
} else if (ArgValue.starts_with("*-")) {
StringValue = ArgValue.slice(1, StringRef::npos);
StringValue = ArgValue.substr(1);
} else if (ArgValue.contains("=")) {
return createStringError(errc::invalid_argument,
"bad format for " + OptionName +
Expand Down Expand Up @@ -608,7 +608,7 @@ parseChangeSectionAddr(StringRef ArgValue, StringRef OptionName,
SectionPattern, SectionMatchStyle, ErrorCallback)))
return std::move(E);

StringRef Value = ArgValue.slice(LastSymbolIndex + 1, StringRef::npos);
StringRef Value = ArgValue.substr(LastSymbolIndex + 1);
if (Value.empty()) {
switch (UpdateSymbol) {
case '+':
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Support/VirtualFileSystemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ class VFSFromYAMLTest : public ::testing::Test {
IntrusiveRefCntPtr<vfs::FileSystem> ExternalFS = new DummyFileSystem(),
StringRef YAMLFilePath = "") {
std::string VersionPlusContent("{\n 'version':0,\n");
VersionPlusContent += Content.slice(Content.find('{') + 1, StringRef::npos);
VersionPlusContent += Content.substr(Content.find('{') + 1);
return getFromYAMLRawString(VersionPlusContent, ExternalFS, YAMLFilePath);
}

Expand Down
Loading