Skip to content

Commit

Permalink
[llvm] Use StringRef::{starts,ends}_with (NFC)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kazutakahirata committed Dec 16, 2023
1 parent 744f389 commit 038871a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/TargetParser/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ StringRef sys::detail::getHostCPUNameForSPARC(StringRef ProcCpuinfoContent) {
// Look for cpu line to determine cpu name
StringRef Cpu;
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
if (Lines[I].startswith("cpu")) {
if (Lines[I].starts_with("cpu")) {
Cpu = Lines[I].substr(5).ltrim("\t :");
break;
}
Expand Down Expand Up @@ -1853,7 +1853,7 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {

// Look for the CPU features.
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("Features")) {
if (Lines[I].starts_with("Features")) {
Lines[I].split(CPUFeatures, ' ');
break;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Support/ProgramTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TEST_F(ProgramEnvTest, CreateProcessLongPath) {
// prefix.
sys::path::native(MyAbsExe, sys::path::Style::windows_backslash);
std::string MyExe;
if (!StringRef(MyAbsExe).startswith("\\\\?\\"))
if (!StringRef(MyAbsExe).starts_with("\\\\?\\"))
MyExe.append("\\\\?\\");
MyExe.append(std::string(MyAbsExe.begin(), MyAbsExe.end()));

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Support/TypeNameTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(TypeNameTest, Names) {
#ifdef __clang__
EXPECT_TRUE(S2Name.ends_with("S2")) << S2Name.str();
#else
EXPECT_TRUE(S2Name.endswith("::S2")) << S2Name.str();
EXPECT_TRUE(S2Name.ends_with("::S2")) << S2Name.str();
#endif
#else
EXPECT_EQ("UNKNOWN_TYPE", S1Name);
Expand Down

0 comments on commit 038871a

Please sign in to comment.