Skip to content

Commit f4f219e

Browse files
authored
[lldb] Handle unsupported type in GetPointerType (#4962)
For `TypeSystemSwiftTypeRef::GetPointerType` to succeed, the given type variable first must be demangled. If that fails, the function must return an empty `CompilerType`. This fixes downstream crashes [in `GetPointerTO` where `Node::addChild` is called](https://github.com/apple/llvm-project/blob/1d75a24ee862516c100d6a540c566349a79c3522/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp#L269), but with a null node. This causes an [abort in `addChild`](https://github.com/apple/swift/blob/380e370157655a102e6cf1abd46b74d575f2ecce/lib/Demangling/Demangler.cpp#L345), where the child node is required to be non-null. rdar://96170947 (cherry picked from #4954)
1 parent 325f869 commit f4f219e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,9 @@ TypeSystemSwiftTypeRef::GetPointerType(opaque_compiler_type_t type) {
24312431

24322432
// The type that will be wrapped in UnsafePointer.
24332433
auto *pointee_type = GetDemangledType(dem, AsMangledName(type));
2434+
if (!pointee_type)
2435+
return {};
2436+
24342437
// The UnsafePointer type.
24352438
auto *pointer_type = dem.createNode(Node::Kind::Type);
24362439

0 commit comments

Comments
 (0)