[Lldb-commits] [lldb] [lldb][Format] Unwrap references to C-strings when printing C-string summaries (PR #174398)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 5 06:55:42 PST 2026


================
@@ -720,7 +720,7 @@ void FormatManager::LoadSystemFormatters() {
   TypeSummaryImpl::Flags string_flags;
   string_flags.SetCascades(true)
       .SetSkipPointers(true)
-      .SetSkipReferences(false)
+      .SetSkipReferences(true)
----------------
Michael137 wrote:

Ok so what seems to happen is that when we `SetSkipReferences` then we don't apply this formatter to references to C-strings. So we don't print a summary for those at all. Previously the summary would have been `<no value available>`:
```
>>> lldb.frame.FindVariable("ref").GetSummary()
'<no value available>'
```

And because we skipped printing a summary (and it wasn't an error), we continue to printing the children: https://github.com/llvm/llvm-project/blob/5a33f99811d29cdf7469104583a30ed854444151/lldb/source/DataFormatters/ValueObjectPrinter.cpp#L123-L129

The child is the `(&ref = "hi")`, which gets formatted with the `char*` system formatter.

So what this patch does is "skip summaries for C-string references and let the child be printed instead".

Feels like a workaround for `${var%s}` not accounting for references more than a proper fix. Let me see if I can fix it in a different way.

https://github.com/llvm/llvm-project/pull/174398


More information about the lldb-commits mailing list