Skip to content

Repair main after merge take 2 #6633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"])
16 changes: 16 additions & 0 deletions lldb/test/API/lang/swift/cxx_interop/backward/expressions/main.cpp
Original file line number Diff line number Diff line change
@@ -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
}

Original file line number Diff line number Diff line change
@@ -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!"
}
}