Skip to content

Commit 0a257a1

Browse files
Merge pull request #10607 from adrian-prantl/reapply-visitor
[lldb] Factor out iteration over runtime types from GetChildCompilerT…
2 parents ebe1ad8 + 4c6a22a commit 0a257a1

File tree

14 files changed

+819
-648
lines changed

14 files changed

+819
-648
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ struct SuperClassType;
6767
using ThreadSafeReflectionContext = LockGuarded<ReflectionContextInterface>;
6868

6969
class SwiftLanguageRuntime : public LanguageRuntime {
70+
friend class SwiftRuntimeTypeVisitor;
71+
7072
protected:
7173
SwiftLanguageRuntime(Process &process);
7274

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

Lines changed: 771 additions & 632 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8627,10 +8627,6 @@ std::string SwiftASTContext::GetSwiftName(const clang::Decl *clang_decl,
86278627
return {};
86288628
}
86298629

8630-
CompilerType SwiftASTContext::GetBuiltinRawPointerType() {
8631-
return GetTypeFromMangledTypename(ConstString("$sBpD"));
8632-
}
8633-
86348630
CompilerType
86358631
SwiftASTContext::ConvertClangTypeToSwiftType(CompilerType clang_type) {
86368632
auto ts = GetTypeSystemSwiftTypeRef();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ class SwiftASTContext : public TypeSystemSwift {
412412
std::string GetSwiftName(const clang::Decl *clang_decl,
413413
TypeSystemClang &clang_typesystem) override;
414414

415-
CompilerType GetBuiltinRawPointerType() override;
416415
CompilerType GetBuiltinIntType();
417416

418417
/// Attempts to convert a Clang type into a Swift type.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ bool TypeSystemSwift::IsScalarType(opaque_compiler_type_t type) {
9898
return (GetTypeInfo(type, nullptr) & eTypeIsScalar) != 0;
9999
}
100100

101+
CompilerType TypeSystemSwift::GetBuiltinRawPointerType() {
102+
return GetTypeFromMangledTypename(ConstString("$sBpD"));
103+
}
104+
105+
CompilerType TypeSystemSwift::GetBuiltinUnknownObjectType() {
106+
return GetTypeFromMangledTypename(ConstString("$sBOD"));
107+
}
108+
101109
bool TypeSystemSwift::ShouldTreatScalarValueAsAddress(
102110
opaque_compiler_type_t type) {
103111
return Flags(GetTypeInfo(type, nullptr))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ class TypeSystemSwift : public TypeSystem {
197197
virtual std::string GetSwiftName(const clang::Decl *clang_decl,
198198
TypeSystemClang &clang_typesystem) = 0;
199199

200-
virtual CompilerType GetBuiltinRawPointerType() = 0;
200+
CompilerType GetBuiltinRawPointerType();
201+
CompilerType GetBuiltinUnknownObjectType();
201202

202203
/// Attempts to convert a Clang type into a Swift type.
203204
/// For example, int is converted to Int32.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,11 +1445,6 @@ TypeSystemSwiftTypeRef::GetSwiftName(const clang::Decl *clang_decl,
14451445
return {};
14461446
}
14471447

1448-
CompilerType TypeSystemSwiftTypeRef::GetBuiltinRawPointerType() {
1449-
return GetTypeFromMangledTypename(ConstString("$sBpD"));
1450-
}
1451-
1452-
14531448
static bool IsImportedType(swift::Demangle::NodePointer node) {
14541449
if (!node)
14551450
return false;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
412412
std::string GetSwiftName(const clang::Decl *clang_decl,
413413
TypeSystemClang &clang_typesystem) override;
414414

415-
CompilerType GetBuiltinRawPointerType() override;
416-
417415
/// Wrap \p node as \p Global(TypeMangling(node)), remangle the type
418416
/// and create a CompilerType from it.
419417
CompilerType RemangleAsType(swift::Demangle::Demangler &dem,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
include Makefile.rules
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
6+
class TestSwiftObjCBaseClassMemberLookup(TestBase):
7+
NO_DEBUG_INFO_TESTCASE = True
8+
@skipUnlessDarwin
9+
@swiftTest
10+
def test(self):
11+
"""Test accessing a static member from a member function"""
12+
self.build()
13+
lldbutil.run_to_source_breakpoint(
14+
self, 'break here', lldb.SBFileSpec('main.swift')
15+
)
16+
17+
p = self.frame().FindVariable("p").GetStaticValue()
18+
self.assertEqual(p.GetNumChildren(), 1)
19+
self.assertEqual(p.GetChildAtIndex(0).GetSummary(), '"hello"')

0 commit comments

Comments
 (0)