[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

Frederic Riss via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 1 15:45:47 PDT 2020


friss added a comment.

I was checking whether there is a way to catch null pointer before a type summary is even chosen. And found out that such logic exists, but only for Objective-C. Languages have a `IsNilReference()` virtual method that can tell whether a `ValueObject` is a nil reference. It's only implemented for ObjectiveC and value objects that test positive for this method are displayed as "nil" is the generic code of `ValueObjectPrinter.cpp`. I can see a few options:

- I can rework the patch to affect only the libc++ string formatter which was the issue I was trying to solve in the first place
- I can implement `IsNilReference()` for C++ and change `ValueObjectPrinter` to print C++ "nil references" as "nullptr".
- I do the above and add another customization point in the Language plugins which tells `ValueObjectPrinter` out to display "nil" references, so that there's no Language specific code in `ValueObjectPrinter`.

A few additional questions come to mind though:

- Was the intent if `IsNilReference()` to be Objective-C specific in the first place?
- Should we do the same thing for C and NULL?
- C, C++ and Objective-C(++) being highly intermingled, would something like this even do the right thing in all cases?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77153/new/

https://reviews.llvm.org/D77153





More information about the lldb-commits mailing list