Skip to content

Commit 546d962

Browse files
committed
[lldb][NFC] Rename functions from Protocol to Existential
SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol and the RemoteAST counterpart actually find the dynamic type of existentials, not "protocol" types. Rename these two functions and references inside them from protocol to existential to more accurately express what they do.
1 parent 8dd381e commit 546d962

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,24 +1945,24 @@ bool SwiftLanguageRuntimeImpl::IsValidErrorValue(ValueObject &in_value) {
19451945
return true;
19461946
}
19471947

1948-
bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
1949-
ValueObject &in_value, CompilerType protocol_type,
1948+
bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Existential(
1949+
ValueObject &in_value, CompilerType existential_type,
19501950
lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name,
19511951
Address &address) {
19521952
Log *log(GetLog(LLDBLog::Types));
19531953
auto tss =
1954-
protocol_type.GetTypeSystem().dyn_cast_or_null<TypeSystemSwift>();
1954+
existential_type.GetTypeSystem().dyn_cast_or_null<TypeSystemSwift>();
19551955
if (!tss) {
19561956
if (log)
19571957
log->Printf("Could not get type system swift");
19581958
return false;
19591959
}
19601960

1961-
const swift::reflection::TypeRef *protocol_typeref =
1962-
GetTypeRef(protocol_type, &tss->GetTypeSystemSwiftTypeRef());
1963-
if (!protocol_typeref) {
1961+
const swift::reflection::TypeRef *existential_typeref =
1962+
GetTypeRef(existential_type, &tss->GetTypeSystemSwiftTypeRef());
1963+
if (!existential_typeref) {
19641964
if (log)
1965-
log->Printf("Could not get protocol typeref");
1965+
log->Printf("Could not get existential typeref");
19661966
return false;
19671967
}
19681968

@@ -2006,7 +2006,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
20062006
return false;
20072007

20082008
auto pair = reflection_ctx->ProjectExistentialAndUnwrapClass(
2009-
remote_existential, *protocol_typeref,
2009+
remote_existential, *existential_typeref,
20102010
tss->GetTypeSystemSwiftTypeRef().GetDescriptorFinder());
20112011
if (use_local_buffer)
20122012
PopLocalBuffer();
@@ -2029,8 +2029,8 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
20292029
#ifndef NDEBUG
20302030
if (ModuleList::GetGlobalModuleListProperties()
20312031
.GetSwiftValidateTypeSystem()) {
2032-
auto reference_pair = GetDynamicTypeAndAddress_ProtocolRemoteAST(
2033-
in_value, protocol_type, use_local_buffer, existential_address);
2032+
auto reference_pair = GetDynamicTypeAndAddress_ExistentialRemoteAST(
2033+
in_value, existential_type, use_local_buffer, existential_address);
20342034
assert(pair.has_value() >= reference_pair.has_value() &&
20352035
"RemoteAST and runtime diverge");
20362036

@@ -2755,7 +2755,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress(
27552755
success = GetDynamicTypeAndAddress_ExistentialMetatype(
27562756
in_value, val_type, use_dynamic, class_type_or_name, address);
27572757
else if (type_info.AnySet(eTypeIsProtocol))
2758-
success = GetDynamicTypeAndAddress_Protocol(in_value, val_type, use_dynamic,
2758+
success = GetDynamicTypeAndAddress_Existential(in_value, val_type, use_dynamic,
27592759
class_type_or_name, address);
27602760
else {
27612761
CompilerType bound_type;
@@ -2778,7 +2778,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress(
27782778
use_dynamic, class_type_or_name,
27792779
address, static_value_type);
27802780
} else if (subst_type_info.AnySet(eTypeIsProtocol)) {
2781-
success = GetDynamicTypeAndAddress_Protocol(
2781+
success = GetDynamicTypeAndAddress_Existential(
27822782
in_value, bound_type, use_dynamic, class_type_or_name, address);
27832783
} else {
27842784
success = GetDynamicTypeAndAddress_Value(in_value, bound_type,

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ class SwiftLanguageRuntimeImpl {
251251
ConstString GetDynamicTypeName_ClassRemoteAST(ValueObject &in_value,
252252
lldb::addr_t instance_ptr);
253253
#endif
254-
bool GetDynamicTypeAndAddress_Protocol(ValueObject &in_value,
254+
bool GetDynamicTypeAndAddress_Existential(ValueObject &in_value,
255255
CompilerType protocol_type,
256256
lldb::DynamicValueType use_dynamic,
257257
TypeAndOrName &class_type_or_name,
258258
Address &address);
259259
#ifndef NDEBUG
260260
std::optional<std::pair<CompilerType, Address>>
261-
GetDynamicTypeAndAddress_ProtocolRemoteAST(ValueObject &in_value,
261+
GetDynamicTypeAndAddress_ExistentialRemoteAST(ValueObject &in_value,
262262
CompilerType protocol_type,
263263
bool use_local_buffer,
264264
lldb::addr_t existential_address);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ ConstString SwiftLanguageRuntimeImpl::GetDynamicTypeName_ClassRemoteAST(
220220
}
221221

222222
std::optional<std::pair<CompilerType, Address>>
223-
SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_ProtocolRemoteAST(
224-
ValueObject &in_value, CompilerType protocol_type, bool use_local_buffer,
223+
SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_ExistentialRemoteAST(
224+
ValueObject &in_value, CompilerType existential_type, bool use_local_buffer,
225225
lldb::addr_t existential_address) {
226226
// Dynamic type resolution in RemoteAST might pull in other Swift
227227
// modules, so use the scratch context where such operations are
@@ -245,7 +245,7 @@ SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_ProtocolRemoteAST(
245245
swift::remote::RemoteAddress remote_existential(existential_address);
246246
auto &remote_ast = GetRemoteASTContext(*swift_ast_ctx);
247247
auto swift_type =
248-
llvm::expectedToStdOptional(swift_ast_ctx->GetSwiftType(protocol_type))
248+
llvm::expectedToStdOptional(swift_ast_ctx->GetSwiftType(existential_type))
249249
.value_or(swift::Type());
250250
if (!swift_type)
251251
return {};

0 commit comments

Comments
 (0)