Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lldb/source/DataFormatters/ValueObjectPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,14 @@ void ValueObjectPrinter::PrintDecl() {
ConstString type_name_cstr(typeName.GetString());
ConstString var_name_cstr(varName.GetString());

DumpValueObjectOptions decl_print_options;
// Pass printing helpers an option object that indicates whether the name
// should be shown or hidden.
decl_print_options.SetHideName(!ShouldShowName());

StreamString dest_stream;
if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr,
m_options, dest_stream)) {
decl_print_options, dest_stream)) {
decl_printed = true;
m_stream->PutCString(dest_stream.GetString());
}
Expand Down
11 changes: 11 additions & 0 deletions lldb/test/API/commands/dwim-print/swift/TestDWIMPrintSwift.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ def test_swift_po_non_address_hex(self):
self, "// break here", lldb.SBFileSpec("main.swift")
)
self.expect(f"dwim-print -O -- 0x1000", substrs=["4096"])

@swiftTest
def test_print_swift_object_does_not_show_name(self):
"""Ensure that objects are printed without a name, and without the '='
that would follow the name."""
self.build()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.swift")
)

self.expect(f"dwim-print user", patterns=[r"^\(a\.User\) 0x[0-9a-f]{7,} \{"])
10 changes: 9 additions & 1 deletion lldb/test/API/commands/dwim-print/swift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ class Object: CustomStringConvertible {
}
}

class User {
var id: Int = 314159265358979322
var name: String = "Gwendolyn"
var groups: (admin: Bool, staff: Bool) = (false, true)
}

func main() {
let object = Object()
_ = object // break here
let user = User()
// break here
print(object, user)
}

main()