[Lldb-commits] [PATCH] D102597: [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 17 00:40:59 PDT 2021


teemperor created this revision.
teemperor added a reviewer: LLDB.
teemperor added a project: LLDB.
Herald added a subscriber: JDevlieghere.
teemperor requested review of this revision.

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 <https://reviews.llvm.org/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 <https://reviews.llvm.org/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.


https://reviews.llvm.org/D102597

Files:
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBLanguageRuntime.cpp
  lldb/source/API/SBPlatform.cpp
  lldb/source/API/SBTypeCategory.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/OptionValue.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Target/ThreadPlanStepInRange.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102597.345772.patch
Type: text/x-patch
Size: 12320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210517/9115f51c/attachment.bin>


More information about the lldb-commits mailing list