Skip to content

Relax validation for GetChildCompilerTypeAtIndex #3650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,8 +1510,18 @@ StripPrivateIDs(swift::Demangle::Demangler &dem,
/// Compare two swift types from different type systems by comparing their
/// (canonicalized) mangled name.
template <> bool Equivalent<CompilerType>(CompilerType l, CompilerType r) {
#ifdef STRICT_VALIDATION
if (!l || !r)
return !l && !r;
#else
// We allow the typeref typesystem to return a type where
// SwiftASTContext fails.
if (!l)
return !r;
if (!r)
return true;
#endif

// See comments in SwiftASTContext::ReconstructType(). For
// SILFunctionTypes the mapping isn't bijective.
auto *ast_ctx = llvm::cast<SwiftASTContext>(r.GetTypeSystem());
Expand Down Expand Up @@ -2727,6 +2737,9 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
if (!ModuleList::GetGlobalModuleListProperties()
.GetSwiftValidateTypeSystem())
return;
// Ignore if SwiftASTContext got no result.
if (ast_child_name.empty())
return;
llvm::StringRef suffix(ast_child_name);
if (suffix.consume_front("__ObjC."))
ast_child_name = suffix.str();
Expand Down