This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Migrate {starts,ends}with_insensitive to {starts,ends}_with_insensitive (NFC)
ClosedPublic

Authored by kazu on May 11 2023, 11:29 PM.

Details

Summary

This patch migrates uses of StringRef::{starts,ends}with_insensitive
to StringRef::{starts,ends}_with_insensitive so that we can use names
similar to those used in std::string_view. I'm planning to deprecate
StringRef::{starts,ends}with_insensitive once the migration is
complete across the code base.

Diff Detail

Event Timeline

kazu created this revision.May 11 2023, 11:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2023, 11:29 PM
kazu requested review of this revision.May 11 2023, 11:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2023, 11:29 PM
dblaikie accepted this revision.May 12 2023, 10:55 AM

Sounds good to me - thanks!

This revision is now accepted and ready to land.May 12 2023, 10:55 AM

I should check - are these function names actually in std::string_view? It doesn't look like it, so renaming them doesn't help us get to the ability to switch to std::string_view, right?

Maybe it'd make more sense to make these non-member functions, so the StringRef API gets closer to string_view?

MaskRay added a subscriber: aaron.ballman.EditedMay 12 2023, 11:00 AM

I should check - are these function names actually in std::string_view? It doesn't look like it, so renaming them doesn't help us get to the ability to switch to std::string_view, right?

Maybe it'd make more sense to make these non-member functions, so the StringRef API gets closer to string_view?

std::string_view::starts_with_insensitive doesn't exist. It (including startswith_insensitive) is a StringRef extension that occurs ~80 times in llvm-project.

(@aaron.ballman)

kazu added a comment.May 12 2023, 11:04 AM

I should check - are these function names actually in std::string_view? It doesn't look like it, so renaming them doesn't help us get to the ability to switch to std::string_view, right?

Maybe it'd make more sense to make these non-member functions, so the StringRef API gets closer to string_view?

std::string_view::starts_with_insensitive doesn't exist. It (including startswith_insensitive) is a StringRef extension that occurs ~80 times in llvm-project.

(@aaron.ballman)

Yes, startswith_insensitive is a StringRef extension.

We should probably tackle StringRef::startswith and StringRef::endswith also, but I'd consult larger audience as they are used in a lot more places.