Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd9a7fc

Browse files
committed
[lldb] Implement TypeSystemSwiftTypeRef::IsPossibleDynamicType
1 parent 4e2bbe2 commit cd9a7fc

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

+38-2
Original file line numberDiff line numberDiff line change
@@ -1764,13 +1764,49 @@ bool TypeSystemSwiftTypeRef::IsFunctionPointerType(
17641764
VALIDATE_AND_RETURN(impl, IsFunctionPointerType, type,
17651765
(ReconstructType(type)));
17661766
}
1767+
17671768
bool TypeSystemSwiftTypeRef::IsPossibleDynamicType(opaque_compiler_type_t type,
17681769
CompilerType *target_type,
17691770
bool check_cplusplus,
17701771
bool check_objc) {
1771-
return m_swift_ast_context->IsPossibleDynamicType(
1772-
ReconstructType(type), target_type, check_cplusplus, check_objc);
1772+
if (target_type)
1773+
target_type->Clear();
1774+
1775+
if (!type)
1776+
return false;
1777+
1778+
auto impl = [&]() {
1779+
using namespace swift::Demangle;
1780+
Demangler dem;
1781+
auto *node = DemangleCanonicalType(dem, type);
1782+
if (!node)
1783+
return false;
1784+
1785+
switch (node->getKind()) {
1786+
case Node::Kind::Class:
1787+
case Node::Kind::BoundGenericClass:
1788+
case Node::Kind::Protocol:
1789+
case Node::Kind::ProtocolList:
1790+
case Node::Kind::ProtocolListWithClass:
1791+
case Node::Kind::DynamicSelf:
1792+
return true;
1793+
case Node::Kind::BuiltinTypeName: {
1794+
if (!node->hasText())
1795+
return false;
1796+
auto name = node->getText();
1797+
return name == swift::BUILTIN_TYPE_NAME_RAWPOINTER ||
1798+
name == swift::BUILTIN_TYPE_NAME_NATIVEOBJECT ||
1799+
name == swift::BUILTIN_TYPE_NAME_BRIDGEOBJECT;
1800+
}
1801+
default:
1802+
return ContainsGenericTypeParameter(node);
1803+
}
1804+
};
1805+
VALIDATE_AND_RETURN(
1806+
impl, IsPossibleDynamicType, type,
1807+
(ReconstructType(type), nullptr, check_cplusplus, check_objc));
17731808
}
1809+
17741810
bool TypeSystemSwiftTypeRef::IsPointerType(opaque_compiler_type_t type,
17751811
CompilerType *pointee_type) {
17761812
auto impl = [&]() {

0 commit comments

Comments
 (0)