Skip to content

[upstreaming] Move GetGenericArgumentType to SwiftASTContext #265

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
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions lldb/include/lldb/Symbol/CompilerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@ class CompilerType {
lldb::TemplateArgumentKind GetTemplateArgumentKind(size_t idx) const;
CompilerType GetTypeTemplateArgument(size_t idx) const;

CompilerType GetGenericArgumentType(size_t idx) const;

// Returns the value of the template argument and its type.
llvm::Optional<IntegralTemplateArgument>
GetIntegralTemplateArgument(size_t idx) const;
Expand Down
3 changes: 2 additions & 1 deletion lldb/include/lldb/Symbol/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ class SwiftASTContext : public TypeSystem {
lldb::GenericKind GetGenericArgumentKind(void *type, size_t idx);
CompilerType GetUnboundGenericType(void *type, size_t idx);
CompilerType GetBoundGenericType(void *type, size_t idx);
CompilerType GetGenericArgumentType(void *type, size_t idx) override;
static CompilerType GetGenericArgumentType(CompilerType ct, size_t idx);
CompilerType GetGenericArgumentType(void *type, size_t idx);

CompilerType GetTypeForFormatters(void *type) override;

Expand Down
2 changes: 0 additions & 2 deletions lldb/include/lldb/Symbol/TypeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ class TypeSystem : public PluginInterface {
virtual llvm::Optional<CompilerType::IntegralTemplateArgument>
GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx);

virtual CompilerType GetGenericArgumentType(void *type, size_t idx);

// Dumping types

#ifndef NDEBUG
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Language/Swift/SwiftArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ SwiftArrayBufferHandler::CreateBufferHandler(ValueObject &valobj) {
swift_runtime->GetMetadataPromise(argmetadata_ptr, valobj));
if (promise_sp)
if (CompilerType type = promise_sp->FulfillTypePromise())
argument_type = type.GetGenericArgumentType(0);
argument_type = SwiftASTContext::GetGenericArgumentType(type, 0);

if (!argument_type.IsValid())
return nullptr;
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/Swift/SwiftHashedContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ HashedCollectionConfig::CreateNativeHandler(
}

if (typeName.startswith(m_nativeStorage_demangledPrefix.GetStringRef())) {
auto key_type = type.GetGenericArgumentType(0);
auto value_type = type.GetGenericArgumentType(1);
auto key_type = SwiftASTContext::GetGenericArgumentType(type, 0);
auto value_type = SwiftASTContext::GetGenericArgumentType(type, 1);
if (key_type.IsValid()) {
return _CreateNativeHandler(dynamic_storage_sp, key_type, value_type);
}
Expand All @@ -377,8 +377,8 @@ HashedCollectionConfig::CreateNativeHandler(
// is some valid storage class instance, and attempt to get
// key/value types from value_sp.
type = value_sp->GetCompilerType();
CompilerType key_type = type.GetGenericArgumentType(0);
CompilerType value_type = type.GetGenericArgumentType(1);
CompilerType key_type = SwiftASTContext::GetGenericArgumentType(type, 0);
CompilerType value_type = SwiftASTContext::GetGenericArgumentType(type, 1);
if (key_type.IsValid()) {
return _CreateNativeHandler(storage_sp, key_type, value_type);
}
Expand Down
7 changes: 0 additions & 7 deletions lldb/source/Symbol/CompilerType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,13 +711,6 @@ CompilerType CompilerType::GetTypeTemplateArgument(size_t idx) const {
return CompilerType();
}

CompilerType CompilerType::GetGenericArgumentType(size_t idx) const {
if (IsValid()) {
return m_type_system->GetGenericArgumentType(m_type, idx);
}
return CompilerType();
}

llvm::Optional<CompilerType::IntegralTemplateArgument>
CompilerType::GetIntegralTemplateArgument(size_t idx) const {
if (IsValid())
Expand Down
12 changes: 12 additions & 0 deletions lldb/source/Symbol/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7724,6 +7724,18 @@ CompilerType SwiftASTContext::GetUnboundGenericType(void *type, size_t idx) {
return {};
}

CompilerType SwiftASTContext::GetGenericArgumentType(CompilerType ct, size_t idx) {
if (!ct)
return {};

SwiftASTContext *ctxt = llvm::dyn_cast<SwiftASTContext>(ct.GetTypeSystem());

if (!ctxt)
return CompilerType();

return ctxt->GetGenericArgumentType(ct.GetOpaqueQualType(), idx);
}

CompilerType SwiftASTContext::GetGenericArgumentType(void *type, size_t idx) {
VALID_OR_RETURN(CompilerType());

Expand Down
4 changes: 0 additions & 4 deletions lldb/source/Symbol/TypeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ CompilerType TypeSystem::GetTypeTemplateArgument(opaque_compiler_type_t type,
return CompilerType();
}

CompilerType TypeSystem::GetGenericArgumentType(void *type, size_t idx) {
return CompilerType();
}

llvm::Optional<CompilerType::IntegralTemplateArgument>
TypeSystem::GetIntegralTemplateArgument(opaque_compiler_type_t type,
size_t idx) {
Expand Down