This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Remove StringRef::withNullAsEmpty
ClosedPublic

Authored by teemperor on May 17 2021, 1:05 AM.

Details

Summary

A long time ago LLDB wanted to start using StringRef instead of
C-Strings/ConstString but was blocked by the StringRef(const char *) ctor
asserting that the C-string isn't a nullptr. To workaround this, D24697
introduced a special function called withNullAsEmpty and that's what LLDB (and
only LLDB) started to use to build StringRefs from C-strings.

A bit later it seems that withNullAsEmpty was declared too awkward to use and
instead the assert in the StringRef constructor got removed (see D24904). The
rest of LLDB was then converted to StringRef by just calling the now perfectly
usable implicit constructor.

However, it seems that the original approach with withNullAsEmpty was never
touched again since then and now just exists as a function in StringRef that
is only used in a few places in LLDB.

I removed the few uses of withNullAsEmpty in D102597 and this patch removes
the function itself. Calling the implicit StringRef(const char *) constructor
is the preferred way of doing this today.

Diff Detail

Event Timeline

totally_not_teemperor requested review of this revision.May 17 2021, 1:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2021, 1:05 AM
teemperor commandeered this revision.May 17 2021, 1:06 AM
teemperor added a reviewer: totally_not_teemperor.
teemperor edited reviewers, added: lattner, mehdi_amini; removed: totally_not_teemperor.
lattner accepted this revision.May 17 2021, 11:33 AM

nice, thanks for cleaning this up!

This revision is now accepted and ready to land.May 17 2021, 11:33 AM
This revision was automatically updated to reflect the committed changes.