Skip to content

Commit b6e360b

Browse files
committed
Simplify handling of protocols as indirect enum cases (NFC)
and remove the SwiftASTContext dependency.
1 parent 2bedd56 commit b6e360b

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
1919
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
2020
#include "Plugins/TypeSystem/Swift/SwiftDemangle.h"
21+
#include "lldb/Core/ValueObjectMemory.h"
2122
#include "lldb/Symbol/Variable.h"
2223
#include "lldb/Symbol/VariableList.h"
2324
#include "lldb/Target/ProcessStructReader.h"
@@ -2043,23 +2044,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_IndirectEnumCase(
20432044
address.SetRawAddress(old_box_value);
20442045
return true;
20452046
} else if (type_info.AllSet(eTypeIsSwift | eTypeIsProtocol)) {
2046-
SwiftASTContext::ProtocolInfo protocol_info;
2047-
if (!SwiftASTContext::GetProtocolTypeInfo(payload_type, protocol_info))
2048-
return false;
2049-
auto ptr_size = m_process.GetAddressByteSize();
2050-
std::vector<uint8_t> buffer(ptr_size * protocol_info.m_num_storage_words,
2051-
0);
2052-
for (uint32_t idx = 0; idx < protocol_info.m_num_storage_words; idx++) {
2053-
lldb::addr_t word = m_process.ReadUnsignedIntegerFromMemory(
2054-
box_value + idx * ptr_size, ptr_size, 0, error);
2055-
if (error.Fail())
2056-
return false;
2057-
memcpy(&buffer[idx * ptr_size], &word, ptr_size);
2058-
}
2059-
DataExtractor data(&buffer[0], buffer.size(), m_process.GetByteOrder(),
2060-
m_process.GetAddressByteSize());
2061-
ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromData(
2062-
"_", data, m_process, payload_type));
2047+
ExecutionContext exe_ctx = in_value.GetExecutionContextRef();
2048+
ValueObjectSP valobj_sp = ValueObjectMemory::Create(
2049+
exe_ctx.GetBestExecutionContextScope(), "_", box_value, payload_type);
20632050
if (!valobj_sp)
20642051
return false;
20652052

0 commit comments

Comments
 (0)