Skip to content

Commit fdda13f

Browse files
committed
Remove TypeSystemSwiftTypeRef::getSwiftType() (NFC)
1 parent 2b18f0d commit fdda13f

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,14 @@ using namespace lldb_private;
4444
namespace lldb_private {
4545
swift::Type GetSwiftType(CompilerType type) {
4646
auto ts = type.GetTypeSystem();
47-
if (auto tr = ts.dyn_cast_or_null<TypeSystemSwiftTypeRef>())
48-
return tr->GetSwiftType(type);
49-
if (auto ast = ts.dyn_cast_or_null<SwiftASTContext>())
50-
return ast->GetSwiftType(type);
47+
if (auto tr = ts.dyn_cast_or_null<TypeSystemSwift>())
48+
if (auto ast = tr->GetSwiftASTContext())
49+
return ast->GetSwiftType(type);
5150
return {};
5251
}
5352

5453
swift::CanType GetCanonicalSwiftType(CompilerType type) {
55-
swift::Type swift_type = nullptr;
56-
auto ts = type.GetTypeSystem();
57-
if (auto tr = ts.dyn_cast_or_null<TypeSystemSwiftTypeRef>())
58-
swift_type = tr->GetSwiftType(type);
59-
if (auto ast = ts.dyn_cast_or_null<SwiftASTContext>())
60-
swift_type = ast->GetSwiftType(type);
54+
swift::Type swift_type = GetSwiftType(type);
6155
return swift_type ? swift_type->getCanonicalType() : swift::CanType();
6256
}
6357

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,28 +210,19 @@ CompilerType SwiftASTContext::GetCompilerType(swift::TypeBase *swift_type) {
210210
return {weak_from_this(), swift_type};
211211
}
212212

213-
swift::Type TypeSystemSwiftTypeRef::GetSwiftType(CompilerType compiler_type) {
214-
auto ts =
215-
compiler_type.GetTypeSystem().dyn_cast_or_null<TypeSystemSwiftTypeRef>();
216-
if (!ts)
217-
return {};
218-
219-
// FIXME: Suboptimal performance, because the ConstString is looked up again.
220-
ConstString mangled_name(
221-
reinterpret_cast<const char *>(compiler_type.GetOpaqueQualType()));
222-
if (auto *swift_ast_context = ts->GetSwiftASTContext())
223-
return swift_ast_context->ReconstructType(mangled_name);
224-
return {};
225-
}
226-
227213
swift::Type SwiftASTContext::GetSwiftType(CompilerType compiler_type) {
228214
if (compiler_type.GetTypeSystem().isa_and_nonnull<SwiftASTContext>())
229215
return reinterpret_cast<swift::TypeBase *>(
230216
compiler_type.GetOpaqueQualType());
231-
if (auto ts = compiler_type.GetTypeSystem()
232-
.dyn_cast_or_null<TypeSystemSwiftTypeRef>())
233-
return ts->GetSwiftType(compiler_type);
234217

218+
// FIXME: Suboptimal performance, because the ConstString is looked up again.
219+
if (auto ts = compiler_type.GetTypeSystem()
220+
.dyn_cast_or_null<TypeSystemSwiftTypeRef>()) {
221+
ConstString mangled_name(
222+
reinterpret_cast<const char *>(compiler_type.GetOpaqueQualType()));
223+
if (auto *swift_ast_context = ts->GetSwiftASTContext())
224+
return swift_ast_context->ReconstructType(mangled_name);
225+
}
235226
return {};
236227
}
237228

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "lldb/Core/SwiftForward.h"
1818
#include "lldb/Core/ThreadSafeDenseMap.h"
1919

20-
#include "swift/AST/Type.h"
21-
2220
// FIXME: needed only for the DenseMap.
2321
#include "clang/APINotes/APINotesManager.h"
2422
#include "clang/Basic/Module.h"
@@ -72,8 +70,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
7270
void ClearModuleDependentCaches() override;
7371
lldb::TargetWP GetTargetWP() const override { return {}; }
7472

75-
swift::CanType GetCanonicalSwiftType(CompilerType compiler_type);
76-
swift::Type GetSwiftType(CompilerType compiler_type);
7773
CompilerType ReconstructType(CompilerType type);
7874
CompilerType
7975
GetTypeFromMangledTypename(ConstString mangled_typename) override;

0 commit comments

Comments
 (0)