diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index bb34b1491fd88..2c8adbe85a6a4 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -2908,7 +2908,7 @@ swift::ASTContext *SwiftASTContext::GetASTContext() { GetLanguageOptions(), GetTypeCheckerOptions(), GetSILOptions(), GetSearchPathOptions(), GetClangImporterOptions(), GetSymbolGraphOptions(), GetSourceManager(), GetDiagnosticEngine(), - ReportModuleLoadingProgress)); + /*OutputBackend=*/nullptr, ReportModuleLoadingProgress)); m_diagnostic_consumer_ap.reset(new StoringDiagnosticConsumer(*this)); if (getenv("LLDB_SWIFT_DUMP_DIAGS")) { diff --git a/lldb/test/API/lang/swift/cxx_interop/backward/expressions/Makefile b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/Makefile new file mode 100644 index 0000000000000..947094ab0c28f --- /dev/null +++ b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/Makefile @@ -0,0 +1,7 @@ +SWIFT_CXX_HEADER := swift-types.h +SWIFT_SOURCES := swift-types.swift +CXX_SOURCES := main.cpp +SWIFT_CXX_INTEROP := 1 +SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR) -parse-as-library +CFLAGS = -I. -g +include Makefile.rules diff --git a/lldb/test/API/lang/swift/cxx_interop/backward/expressions/TestSwiftBackwardInteropExpressions.py b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/TestSwiftBackwardInteropExpressions.py new file mode 100644 index 0000000000000..4ca2caeecc6eb --- /dev/null +++ b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/TestSwiftBackwardInteropExpressions.py @@ -0,0 +1,22 @@ + +""" +Test that evaluating expressions works on backward interop mode. +""" +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestSwiftBackwardInteropExpressions(TestBase): + + @skipIfLinux + @swiftTest + def test_func_step_in(self): + self.build() + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') + _, _, _, _ = lldbutil.run_to_source_breakpoint( + self, 'Break here', lldb.SBFileSpec('main.cpp')) + self.expect('expr swiftFunc()', substrs=["Inside a Swift function"]) + self.expect('expr swiftClass.swiftMethod()', substrs=["Inside a Swift method"]) + self.expect('expr a::SwiftClass::swiftStaticMethod()', substrs=["In a Swift static method"]) + self.expect('expr swiftClass.getSwiftProperty()', substrs=["This is a class with properties"]) + self.expect('expr swiftSubclassAsClass.overrideableMethod()', substrs=["In subclass"]) diff --git a/lldb/test/API/lang/swift/cxx_interop/backward/expressions/main.cpp b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/main.cpp new file mode 100644 index 0000000000000..17431c746188a --- /dev/null +++ b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/main.cpp @@ -0,0 +1,16 @@ +#include "swift-types.h" + +using namespace a; + +int main() { + swiftFunc(); + auto swiftClass = SwiftClass::init(); + swiftClass.swiftMethod(); + SwiftClass::swiftStaticMethod(); + swiftClass.getSwiftProperty(); + auto swiftSubclass = SwiftSubclass::init(); + SwiftClass swiftSubclassAsClass = swiftSubclass; + swiftSubclassAsClass.overrideableMethod(); + return 0; // Break here +} + diff --git a/lldb/test/API/lang/swift/cxx_interop/backward/expressions/swift-types.swift b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/swift-types.swift new file mode 100644 index 0000000000000..8a74c3e4c28c6 --- /dev/null +++ b/lldb/test/API/lang/swift/cxx_interop/backward/expressions/swift-types.swift @@ -0,0 +1,39 @@ + +public func swiftFunc() -> String{ + return "Inside a Swift function!" +} + +public class SwiftClass { + var field: Int + var arr: [String] + public init() { + field = 42 + arr = ["An", "array", "of", "strings"] + } + + public func swiftMethod() -> String { + return "Inside a Swift method!" + } + + private var _desc = "This is a class with properties!" + public var swiftProperty: String { + get { + return _desc + } + } + + public static func swiftStaticMethod() -> String { + return "In a Swift static method!" + } + + public func overrideableMethod() -> String { + return "In the base class!" + } +} + +public class SwiftSubclass: SwiftClass { + public override func overrideableMethod() -> String { + return "In subclass!" + } +} +