Skip to content

Commit 009a6f3

Browse files
committed
[lldb] Add Swift/C++ test for C++ typedefs, C++ using, and Swift typealiases.
rdar://100284870
1 parent d8093c5 commit 009a6f3

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3128,7 +3128,9 @@ TypeSystemSwiftTypeRef::ShouldPrintAsOneLiner(opaque_compiler_type_t type,
31283128
ValueObject *valobj) {
31293129
auto impl = [&]() {
31303130
if (type) {
3131-
if (IsImportedType(type, nullptr))
3131+
auto canonical = GetCanonicalType(type);
3132+
if (canonical)
3133+
if (IsImportedType(canonical.GetOpaqueQualType(), nullptr))
31323134
return eLazyBoolNo;
31333135
}
31343136
if (valobj) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFT_CXX_INTEROP := 1
3+
SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR)
4+
include Makefile.rules
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
"""
3+
Test that printing C++ types with typedefs, using, and Swift typealiases print correctly in Swift
4+
"""
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test.decorators import *
7+
8+
9+
class TestTypedefType(TestBase):
10+
11+
@swiftTest
12+
def test_class(self):
13+
self.build()
14+
self.runCmd('setting set target.experimental.swift-enable-cxx-interop true')
15+
_, _, _, _= lldbutil.run_to_source_breakpoint(
16+
self, 'Set breakpoint here', lldb.SBFileSpec('main.swift'))
17+
18+
self.expect('v typedef', substrs=['TypedefedCxxClass', 'a1', '10', 'a2', '20', 'a3', '30'])
19+
self.expect('expr typedef', substrs=['TypedefedCxxClass', 'a1', '10', 'a2', '20', 'a3', '30'])
20+
21+
self.expect('v using', substrs=['UsingCxxClass', 'a1', '10', 'a2', '20', 'a3', '30'])
22+
self.expect('expr using', substrs=['UsingCxxClass', 'a1', '10', 'a2', '20', 'a3', '30'])
23+
24+
self.expect('v typealiased', substrs=['TypeAliased', 'a1', '10', 'a2', '20', 'a3', '30'])
25+
self.expect('expr typealiased', substrs=['TypeAliased', 'a1', '10', 'a2', '20', 'a3', '30'])
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import ReturnsClass
2+
3+
typealias TypeAliased = CxxClass
4+
5+
func main() {
6+
let typedef = TypedefedCxxClass()
7+
let using = UsingCxxClass()
8+
let typealiased = TypeAliased()
9+
print(1) // Set breakpoint here
10+
}
11+
main()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ReturnsClass {
2+
header "returns-class.h"
3+
requires cplusplus
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
struct CxxClass {
3+
long long a1 = 10;
4+
long long a2 = 20;
5+
long long a3 = 30;
6+
};
7+
8+
9+
typedef CxxClass TypedefedCxxClass;
10+
using UsingCxxClass = CxxClass;

0 commit comments

Comments
 (0)