Skip to content

Commit 0db9065

Browse files
authored
Merge pull request #260 from Teemperor/MoveGetInstanceTypeMaster
[upstreaming] Move GetInstanceType to SwiftASTContext
2 parents f40fa3c + e4fa3ad commit 0db9065

File tree

10 files changed

+18
-22
lines changed

10 files changed

+18
-22
lines changed

lldb/include/lldb/Symbol/ClangASTContext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ class ClangASTContext : public TypeSystem {
648648

649649
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
650650

651-
CompilerType GetInstanceType(lldb::opaque_compiler_type_t type) override;
652-
653651
CompilerType
654652
GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
655653

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ class CompilerType {
181181

182182
CompilerType GetCanonicalType() const;
183183

184-
CompilerType GetInstanceType() const;
185-
186184
CompilerType GetFullyUnqualifiedType() const;
187185

188186
// Returns -1 if this isn't a function of if the function doesn't have a

lldb/include/lldb/Symbol/SwiftASTContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ class SwiftASTContext : public TypeSystem {
521521

522522
CompilerType GetCanonicalType(void *type) override;
523523

524-
CompilerType GetInstanceType(void *type) override;
524+
static CompilerType GetInstanceType(CompilerType ct);
525+
CompilerType GetInstanceType(void *type);
525526

526527
// Returns -1 if this isn't a function of if the function doesn't have a
527528
// prototype. Returns a value >override if there is a prototype.

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ class TypeSystem : public PluginInterface {
261261

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

264-
virtual CompilerType GetInstanceType(lldb::opaque_compiler_type_t type) = 0;
265-
266264
// Returns -1 if this isn't a function of if the function doesn't have a
267265
// prototype Returns a value >= 0 if there is a prototype.
268266
virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;

lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void SwiftUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
223223
Flags self_type_flags(self_type.GetTypeInfo());
224224

225225
if (self_type_flags.AllSet(lldb::eTypeIsSwift | lldb::eTypeIsMetatype)) {
226-
self_type = self_type.GetInstanceType();
226+
self_type = SwiftASTContext::GetInstanceType(self_type);
227227
self_type_flags = self_type.GetTypeInfo();
228228
if (self_type_flags.Test(lldb::eTypeIsClass))
229229
m_is_class = true;

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
12371237
CompilerType result_type(result_sp->GetCompilerType());
12381238
if (Flags(result_type.GetTypeInfo())
12391239
.AllSet(eTypeIsSwift | eTypeIsMetatype))
1240-
result_type = result_type.GetInstanceType();
1240+
result_type = SwiftASTContext::GetInstanceType(result_type);
12411241
results.insert(TypeOrDecl(result_type));
12421242
}
12431243
}

lldb/source/Plugins/Language/Swift/SwiftMetatype.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ bool lldb_private::formatters::swift::SwiftMetatype_SummaryProvider(
2929
lldb::addr_t metadata_ptr = valobj.GetPointerValue();
3030
if (metadata_ptr == LLDB_INVALID_ADDRESS || metadata_ptr == 0) {
3131
CompilerType compiler_metatype_type(valobj.GetCompilerType());
32-
CompilerType instancetype(compiler_metatype_type.GetInstanceType());
32+
CompilerType instancetype =
33+
SwiftASTContext::GetInstanceType(compiler_metatype_type);
3334

3435
const char *ptr = instancetype.GetDisplayTypeName().AsCString(nullptr);
3536
if (ptr && *ptr) {

lldb/source/Symbol/ClangASTContext.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,12 +4538,6 @@ ClangASTContext::GetCanonicalType(lldb::opaque_compiler_type_t type) {
45384538
return CompilerType();
45394539
}
45404540

4541-
CompilerType ClangASTContext::GetInstanceType(void *type) {
4542-
if (type)
4543-
return CompilerType(this, GetQualType(type).getAsOpaquePtr());
4544-
return CompilerType();
4545-
}
4546-
45474541
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast,
45484542
clang::QualType qual_type) {
45494543
if (qual_type->isPointerType())

lldb/source/Symbol/CompilerType.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,6 @@ CompilerType CompilerType::GetCanonicalType() const {
374374
return CompilerType();
375375
}
376376

377-
CompilerType CompilerType::GetInstanceType() const {
378-
if (IsValid())
379-
return m_type_system->GetInstanceType(m_type);
380-
return CompilerType();
381-
}
382-
383377
CompilerType CompilerType::GetFullyUnqualifiedType() const {
384378
if (IsValid())
385379
return m_type_system->GetFullyUnqualifiedType(m_type);

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5880,6 +5880,18 @@ CompilerType SwiftASTContext::GetCanonicalType(void *type) {
58805880
return CompilerType();
58815881
}
58825882

5883+
CompilerType SwiftASTContext::GetInstanceType(CompilerType ct) {
5884+
if (!ct)
5885+
return {};
5886+
5887+
SwiftASTContext *ctxt = llvm::dyn_cast<SwiftASTContext>(ct.GetTypeSystem());
5888+
5889+
if (!ctxt)
5890+
return CompilerType();
5891+
5892+
return ctxt->GetInstanceType(ct.GetOpaqueQualType());
5893+
}
5894+
58835895
CompilerType SwiftASTContext::GetInstanceType(void *type) {
58845896
VALID_OR_RETURN(CompilerType());
58855897

0 commit comments

Comments
 (0)