Skip to content

[upstreaming] Move GetInstanceType to SwiftASTContext #260

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/ClangASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ class ClangASTContext : public TypeSystem {

CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;

CompilerType GetInstanceType(lldb::opaque_compiler_type_t type) override;

CompilerType
GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;

Expand Down
2 changes: 0 additions & 2 deletions lldb/include/lldb/Symbol/CompilerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ class CompilerType {

CompilerType GetCanonicalType() const;

CompilerType GetInstanceType() const;

CompilerType GetFullyUnqualifiedType() const;

// Returns -1 if this isn't a function of if the function doesn't have a
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 @@ -522,7 +522,8 @@ class SwiftASTContext : public TypeSystem {

CompilerType GetCanonicalType(void *type) override;

CompilerType GetInstanceType(void *type) override;
static CompilerType GetInstanceType(CompilerType ct);
CompilerType GetInstanceType(void *type);

// Returns -1 if this isn't a function of if the function doesn't have a
// prototype. Returns a value >override if there is a prototype.
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 @@ -262,8 +262,6 @@ class TypeSystem : public PluginInterface {

virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;

virtual CompilerType GetInstanceType(lldb::opaque_compiler_type_t type) = 0;

// Returns -1 if this isn't a function of if the function doesn't have a
// prototype Returns a value >= 0 if there is a prototype.
virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void SwiftUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
Flags self_type_flags(self_type.GetTypeInfo());

if (self_type_flags.AllSet(lldb::eTypeIsSwift | lldb::eTypeIsMetatype)) {
self_type = self_type.GetInstanceType();
self_type = SwiftASTContext::GetInstanceType(self_type);
self_type_flags = self_type.GetTypeInfo();
if (self_type_flags.Test(lldb::eTypeIsClass))
m_is_class = true;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
CompilerType result_type(result_sp->GetCompilerType());
if (Flags(result_type.GetTypeInfo())
.AllSet(eTypeIsSwift | eTypeIsMetatype))
result_type = result_type.GetInstanceType();
result_type = SwiftASTContext::GetInstanceType(result_type);
results.insert(TypeOrDecl(result_type));
}
}
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/Language/Swift/SwiftMetatype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ bool lldb_private::formatters::swift::SwiftMetatype_SummaryProvider(
lldb::addr_t metadata_ptr = valobj.GetPointerValue();
if (metadata_ptr == LLDB_INVALID_ADDRESS || metadata_ptr == 0) {
CompilerType compiler_metatype_type(valobj.GetCompilerType());
CompilerType instancetype(compiler_metatype_type.GetInstanceType());
CompilerType instancetype =
SwiftASTContext::GetInstanceType(compiler_metatype_type);

const char *ptr = instancetype.GetDisplayTypeName().AsCString(nullptr);
if (ptr && *ptr) {
Expand Down
6 changes: 0 additions & 6 deletions lldb/source/Symbol/ClangASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4538,12 +4538,6 @@ ClangASTContext::GetCanonicalType(lldb::opaque_compiler_type_t type) {
return CompilerType();
}

CompilerType ClangASTContext::GetInstanceType(void *type) {
if (type)
return CompilerType(this, GetQualType(type).getAsOpaquePtr());
return CompilerType();
}

static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast,
clang::QualType qual_type) {
if (qual_type->isPointerType())
Expand Down
6 changes: 0 additions & 6 deletions lldb/source/Symbol/CompilerType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,6 @@ CompilerType CompilerType::GetCanonicalType() const {
return CompilerType();
}

CompilerType CompilerType::GetInstanceType() const {
if (IsValid())
return m_type_system->GetInstanceType(m_type);
return CompilerType();
}

CompilerType CompilerType::GetFullyUnqualifiedType() const {
if (IsValid())
return m_type_system->GetFullyUnqualifiedType(m_type);
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 @@ -5877,6 +5877,18 @@ CompilerType SwiftASTContext::GetCanonicalType(void *type) {
return CompilerType();
}

CompilerType SwiftASTContext::GetInstanceType(CompilerType ct) {
if (!ct)
return {};

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

if (!ctxt)
return CompilerType();

return ctxt->GetInstanceType(ct.GetOpaqueQualType());
}

CompilerType SwiftASTContext::GetInstanceType(void *type) {
VALID_OR_RETURN(CompilerType());

Expand Down