[Lldb-commits] [PATCH] D77843: [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 28 15:40:41 PDT 2020


shafik added inline comments.


================
Comment at: lldb/source/DataFormatters/StringPrinter.cpp:175
+  constexpr unsigned max_buffer_size = 7;
+  uint8_t *data = new uint8_t[max_buffer_size];
+  switch (escape_style) {
----------------
I really wish we could get ride of the naked `new`. It seems possible.

- We know the buffer size
- We know the "expected" escaped_len
- We could write something like a `make_StringPrinterBufferPointer` in the same spirit as `make_unique`

The problem we want to avoid w/ the naked `new` is that the code becomes more complicated over time and somehow a later change disconnects the `new` w/ the creation of the `StringPrinterBufferPointer` which manages the lifetime. 

This comment applies to the code later on as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77843





More information about the lldb-commits mailing list