Fix LLDB after the pointer nullability changes. Thanks to Jordan for putting most of this patch together
diff --git a/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp b/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp
index 5b2d4cb..2c5912b 100644
--- a/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp
+++ b/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp
@@ -68,7 +68,7 @@
{
const char *name = binding.name;
- wrapped_stream.Printf(", _ __lldb_placeholder_%s : UnsafePointer<%s>", name, name);
+ wrapped_stream.Printf(", _ __lldb_placeholder_%s : UnsafePointer<%s>!", name, name);
}
}
@@ -80,7 +80,7 @@
for (const Expression::SwiftGenericInfo::Binding &binding : generic_bindings)
{
wrapped_stream.Printf(",\n"
- " UnsafePointer<$__lldb_typeof_generic_%s>(nil)", binding.name);
+ " (nil as UnsafePointer<$__lldb_typeof_generic_%s>?)", binding.name);
}
}
diff --git a/source/Plugins/Language/Swift/SwiftFormatters.cpp b/source/Plugins/Language/Swift/SwiftFormatters.cpp
index b3efe2d..b59cb6c 100644
--- a/source/Plugins/Language/Swift/SwiftFormatters.cpp
+++ b/source/Plugins/Language/Swift/SwiftFormatters.cpp
@@ -138,6 +138,7 @@
bool
lldb_private::formatters::swift::StringCore_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options, StringPrinter::ReadStringAndDumpToStreamOptions read_options)
{
+ static ConstString g_some("some");
static ConstString g__baseAddress("_baseAddress");
static ConstString g__countAndFlags("_countAndFlags");
static ConstString g_value("_value");
@@ -146,13 +147,13 @@
ProcessSP process_sp(valobj.GetProcessSP());
if (!process_sp)
return false;
- ValueObjectSP baseAddress_sp(valobj.GetChildAtNamePath({ g__baseAddress, g__rawValue }));
+ ValueObjectSP baseAddress_sp(valobj.GetChildAtNamePath({ g__baseAddress, g_some, g__rawValue }));
ValueObjectSP _countAndFlags_sp(valobj.GetChildAtNamePath({ g__countAndFlags, g_value }));
- if (!baseAddress_sp || !_countAndFlags_sp)
+ if (!_countAndFlags_sp)
return false;
- lldb::addr_t baseAddress = baseAddress_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ lldb::addr_t baseAddress = baseAddress_sp ? baseAddress_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS) : 0;
InferiorSizedWord _countAndFlags = InferiorSizedWord(_countAndFlags_sp->GetValueAsUnsigned(0),*process_sp.get());
if (baseAddress == LLDB_INVALID_ADDRESS)
diff --git a/source/Target/SwiftLanguageRuntime.cpp b/source/Target/SwiftLanguageRuntime.cpp
index 9c56074..29be272 100644
--- a/source/Target/SwiftLanguageRuntime.cpp
+++ b/source/Target/SwiftLanguageRuntime.cpp
@@ -298,7 +298,7 @@
}
StreamString expr_string;
- expr_string.Printf("$__lldb__DumpForDebugger(Swift.UnsafePointer<%s>(bitPattern: 0x%" PRIx64 ").pointee)",static_type.GetTypeName().GetCString(),copy_location);
+ expr_string.Printf("$__lldb__DumpForDebugger(Swift.UnsafePointer<%s>(bitPattern: 0x%" PRIx64 ")!.pointee)",static_type.GetTypeName().GetCString(),copy_location);
if (log)
log->Printf("[GetObjectDescription_ObjectCopy] expression: %s", expr_string.GetData());