This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB
ClosedPublic

Authored by teemperor on May 17 2021, 12:40 AM.

Details

Summary

A long time ago LLDB wanted to start using StringRef instead of C-Strings/ConstString but
was blocked by the fact that the StringRef constructor that takes a C-string was 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, all the calls to withNullAsEmpty just remained and are now just strange
artefacts in the code base that just look out of place. It's also curiously a LLDB-exclusive
function and no other project ever called it since it's introduction half a decade ago.

This patch removes all uses of withNullAsEmpty. The follow up will be to remove the
function from StringRef.

Diff Detail