diff --git a/lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp b/lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp index 7ec651ea61560..ed58b44abad63 100644 --- a/lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp +++ b/lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp @@ -302,7 +302,8 @@ Status SwiftREPL::DoInitialization() { return Status::FromError(type_system_or_err.takeError()); std::static_pointer_cast( *type_system_or_err) - ->SetCompilerOptions(m_compiler_options.c_str()); + ->SetCompilerOptions(/*repl=*/true, /*playgrounds=*/false, + m_compiler_options.c_str()); std::string format_str = "${ansi.negative}Swift " + swift::version::getCompilerVersion() + diff --git a/lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp index 900978bf98f7d..d5176ec85b515 100644 --- a/lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp @@ -805,7 +805,9 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager, "unknown error"); // Notify SwiftASTContext that this is a Playground. if (m_options.GetPlaygroundTransformEnabled()) - m_swift_scratch_ctx->SetCompilerOptions(""); + m_swift_scratch_ctx->SetCompilerOptions( + m_options.GetREPLEnabled(), m_options.GetPlaygroundTransformEnabled(), + ""); // For playgrounds, the target triple should be used for expression // evaluation, not the current module. This requires disabling precise diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index 37dba6a359b9b..988371236c2f0 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -2689,16 +2689,14 @@ static lldb::ModuleSP GetUnitTestModule(lldb_private::ModuleList &modules) { return ModuleSP(); } -lldb::TypeSystemSP -SwiftASTContext::CreateInstance(const SymbolContext &sc, - TypeSystemSwiftTypeRef &typeref_typesystem, - const char *extra_options) { - bool is_repl = extra_options; +lldb::TypeSystemSP SwiftASTContext::CreateInstance( + const SymbolContext &sc, TypeSystemSwiftTypeRef &typeref_typesystem, + bool repl, bool playground, const char *extra_options) { bool for_expressions = llvm::isa(&typeref_typesystem); // REPL requires an expression type system. - assert(!is_repl || for_expressions); - if (is_repl && !for_expressions) + assert(!repl || for_expressions); + if (repl && !for_expressions) return {}; if (!ModuleList::GetGlobalModuleListProperties() @@ -2707,6 +2705,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, CompileUnit *cu = sc.comp_unit; const char *key = TypeSystemSwiftTypeRef::DeriveKeyFor(sc); + bool swift_context = cu && cu->GetLanguage() == eLanguageTypeSwift; std::string m_description; { StreamString ss; @@ -2714,19 +2713,16 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, if (for_expressions) ss << "ForExpressions"; ss << "(module: " << '"' << key << "\", " << "cu: " << '"'; - if (cu) + if (cu && swift_context) ss << cu->GetPrimaryFile().GetFilename(); else - ss << "null"; + ss << "*"; ss << '"' << ')'; m_description = ss.GetString(); } LLDB_SCOPED_TIMERF("%s::CreateInstance", m_description.c_str()); - if (is_repl) - LOG_PRINTF(GetLog(LLDBLog::Types), "REPL detected"); - // This function can either create an expression/scratch/repl context, // or a SwiftAST fallback context for a TypeSystemSwiftTyperef. // - SwiftASTContexForExpressions: target=non-null, module=null. @@ -2770,8 +2766,9 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, if (ShouldEnableEmbeddedSwift(cu)) lang_opts.enableFeature(swift::Feature::Embedded); } - auto defer_log = llvm::make_scope_exit( - [swift_ast_sp, is_repl] { swift_ast_sp->LogConfiguration(is_repl); }); + auto defer_log = llvm::make_scope_exit([swift_ast_sp, repl, playground] { + swift_ast_sp->LogConfiguration(repl, playground); + }); LOG_PRINTF(GetLog(LLDBLog::Types), "(Target)"); auto logError = [&](const char *message) { @@ -2797,7 +2794,12 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, ModuleList module_module; if (!target_sp) module_module.Append(module_sp); - ModuleList &modules = target_sp ? target_sp->GetImages() : module_module; + // Leave modules empty if not in a Swift context to avoid a fragile + // and expensive scan through all images. Unless this is a Playground, which + // has a non-Swift executable, and user code in a framework. + ModuleList &modules = (target_sp && (swift_context || playground)) + ? target_sp->GetImages() + : module_module; const size_t num_images = modules.GetSize(); // Set the SDK path prior to doing search paths. Otherwise when we @@ -2869,7 +2871,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, ArchSpec preferred_arch; llvm::Triple preferred_triple; - if (is_repl) { + if (repl) { LOG_PRINTF(GetLog(LLDBLog::Types), "REPL: prefer target triple."); preferred_arch = target_arch; preferred_triple = target_triple; @@ -3133,7 +3135,8 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, } } }; - scan_module(module_sp, 0); + if (swift_context || playground) + scan_module(module_sp, 0); for (size_t mi = 0; mi != num_images; ++mi) { auto image_sp = modules.GetModuleAtIndex(mi); if (!visited_modules.count(image_sp.get())) @@ -5461,7 +5464,7 @@ void SwiftASTContext::ClearModuleDependentCaches() { m_negative_type_cache.Clear(); } -void SwiftASTContext::LogConfiguration(bool is_repl) { +void SwiftASTContext::LogConfiguration(bool repl, bool playground) { // It makes no sense to call VALID_OR_RETURN here. We specifically // want the logs in the error case! HEALTH_LOG_PRINTF("(SwiftASTContext*)%p:", static_cast(this)); @@ -5471,8 +5474,10 @@ void SwiftASTContext::LogConfiguration(bool is_repl) { HEALTH_LOG_PRINTF(" (no AST context)"); return; } - if (is_repl) + if (repl) HEALTH_LOG_PRINTF(" REPL : true"); + if (playground) + HEALTH_LOG_PRINTF(" Playground : true"); HEALTH_LOG_PRINTF(" Swift/C++ interop : %s", ast_context->LangOpts.EnableCXXInterop ? "on" : "off"); HEALTH_LOG_PRINTF(" Swift/Objective-C interop : %s", diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h index 36d742c20a8c1..e1343e94570c9 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h @@ -207,8 +207,8 @@ class SwiftASTContext : public TypeSystemSwift { /// context. static lldb::TypeSystemSP CreateInstance(const SymbolContext &sc, - TypeSystemSwiftTypeRef &typeref_typesystem, - const char *extra_options = nullptr); + TypeSystemSwiftTypeRef &typeref_typesystem, bool repl = false, + bool playground = false, const char *extra_options = nullptr); static void EnumerateSupportedLanguages( std::set &languages_for_types, @@ -539,7 +539,7 @@ class SwiftASTContext : public TypeSystemSwift { swift::TBDGenOptions &GetTBDGenOptions(); void ClearModuleDependentCaches() override; - void LogConfiguration(bool is_repl = false); + void LogConfiguration(bool repl = false, bool playground = false); bool HasTarget(); bool HasExplicitModules() const { return m_has_explicit_modules; } bool CheckProcessChanged(); diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp index a391acc25bf0f..cda4161a07d21 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp @@ -45,8 +45,8 @@ static lldb::TypeSystemSP CreateTypeSystemInstance(lldb::LanguageType language, } else if (target) { assert(!module); return std::shared_ptr( - new TypeSystemSwiftTypeRefForExpressions(language, *target, - extra_options)); + new TypeSystemSwiftTypeRefForExpressions(language, *target, false, + false, extra_options)); } llvm_unreachable("Neither type nor module given to CreateTypeSystemInstance"); } diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp index 7d670ac3fc409..abd9f5444a37e 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp @@ -1963,7 +1963,8 @@ TypeSystemSwiftTypeRef::TypeSystemSwiftTypeRef(Module &module) { } TypeSystemSwiftTypeRefForExpressions::TypeSystemSwiftTypeRefForExpressions( - lldb::LanguageType language, Target &target, const char *extra_options) + lldb::LanguageType language, Target &target, bool repl, bool playground, + const char *extra_options) : m_target_wp(target.shared_from_this()), m_persistent_state_up(new SwiftPersistentExpressionState) { m_description = "TypeSystemSwiftTypeRefForExpressions"; @@ -1971,7 +1972,8 @@ TypeSystemSwiftTypeRefForExpressions::TypeSystemSwiftTypeRefForExpressions( "%s::TypeSystemSwiftTypeRefForExpressions()", m_description.c_str()); // Is this a REPL or Playground? - if (extra_options) { + assert(!repl && !playground && !extra_options && "use SetCompilerOptions()"); + if (repl || playground || extra_options) { SymbolContext global_sc(target.shared_from_this(), target.GetExecutableModule()); const char *key = DeriveKeyFor(global_sc); @@ -1979,8 +1981,8 @@ TypeSystemSwiftTypeRefForExpressions::TypeSystemSwiftTypeRefForExpressions( {key, {SwiftASTContext::CreateInstance( global_sc, - *const_cast(this), - extra_options), + *const_cast(this), repl, + playground, extra_options), 0}}); } } @@ -2072,15 +2074,14 @@ ConstString TypeSystemSwiftTypeRef::GetSwiftModuleFor(const SymbolContext &sc) { } const char *TypeSystemSwiftTypeRef::DeriveKeyFor(const SymbolContext &sc) { - if (sc.function) + if (sc.comp_unit && sc.comp_unit->GetLanguage() == eLanguageTypeSwift) if (ConstString name = GetSwiftModuleFor(sc)) return name.GetCString(); - if (sc.module_sp) { - if (sc.module_sp->GetFileSpec()) - return sc.module_sp->GetFileSpec().GetFilename().GetCString(); - return sc.module_sp->GetObjectName().GetCString(); - } + // Otherwise create a catch-all context per unique triple. + if (sc.module_sp) + return ConstString(sc.module_sp->GetArchitecture().GetTriple().str()).AsCString(); + return nullptr; } @@ -2184,8 +2185,8 @@ SwiftASTContextSP TypeSystemSwiftTypeRefForExpressions::GetSwiftASTContext( // Create a new SwiftASTContextForExpressions. ts = SwiftASTContext::CreateInstance( - sc, *const_cast(this), - m_compiler_options); + sc, *const_cast(this), m_repl, + m_playground, m_compiler_options); m_swift_ast_context_map.insert({key, {ts, retry_count}}); } @@ -2563,6 +2564,9 @@ template <> bool Equivalent(CompilerType l, CompilerType r) { ConstString rhs = r.GetMangledTypeName(); if (lhs == ConstString("$sSiD") && rhs == ConstString("$sSuD")) return true; + if (lhs.GetStringRef() == "$sSPySo0023unnamedstruct_hEEEdhdEaVGSgD" && + rhs.GetStringRef() == "$ss13OpaquePointerVSgD") + return true; // Ignore missing sugar. swift::Demangle::Demangler dem; auto l_node = GetDemangledType(dem, lhs.GetStringRef()); diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h index f58ccbb935f6c..998ad74efcee9 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h @@ -626,7 +626,8 @@ class TypeSystemSwiftTypeRefForExpressions : public TypeSystemSwiftTypeRef { /// \} TypeSystemSwiftTypeRefForExpressions(lldb::LanguageType language, - Target &target, + Target &target, bool repl, + bool playground, const char *extra_options); static TypeSystemSwiftTypeRefForExpressionsSP GetForTarget(Target &target); @@ -638,7 +639,10 @@ class TypeSystemSwiftTypeRefForExpressions : public TypeSystemSwiftTypeRef { GetSwiftASTContextOrNull(const SymbolContext &sc) const override; /// This API needs to be called for a REPL or Playground before the first call /// to GetSwiftASTContext is being made. - void SetCompilerOptions(const char *compiler_options) { + void SetCompilerOptions(bool repl, bool playground, + const char *compiler_options) { + m_repl = repl; + m_playground = playground; m_compiler_options = compiler_options; } lldb::TargetWP GetTargetWP() const override { return m_target_wp; } @@ -668,6 +672,8 @@ class TypeSystemSwiftTypeRefForExpressions : public TypeSystemSwiftTypeRef { protected: lldb::TargetWP m_target_wp; unsigned m_generation = 0; + bool m_repl = false; + bool m_playground = false; const char *m_compiler_options = nullptr; /// This exists to implement the PerformCompileUnitImports diff --git a/lldb/test/API/lang/swift/playgrounds/AuxSources.swift b/lldb/test/API/lang/swift/playgrounds/AuxSources.swift new file mode 100644 index 0000000000000..68007d8c23488 --- /dev/null +++ b/lldb/test/API/lang/swift/playgrounds/AuxSources.swift @@ -0,0 +1 @@ +// This file intentionally left blank. diff --git a/lldb/test/API/lang/swift/playgrounds/Import.swift b/lldb/test/API/lang/swift/playgrounds/Import.swift index 6dd7f74e24de3..290716e28d06c 100644 --- a/lldb/test/API/lang/swift/playgrounds/Import.swift +++ b/lldb/test/API/lang/swift/playgrounds/Import.swift @@ -1,3 +1,4 @@ +import AuxSources import Dylib f() let comment = "and back again" diff --git a/lldb/test/API/lang/swift/playgrounds/Makefile b/lldb/test/API/lang/swift/playgrounds/Makefile index 6f19e462aca64..4e58d55064309 100644 --- a/lldb/test/API/lang/swift/playgrounds/Makefile +++ b/lldb/test/API/lang/swift/playgrounds/Makefile @@ -1,12 +1,14 @@ EXE = PlaygroundStub SWIFT_SOURCES = PlaygroundStub.swift +# The real playground stub has no debug info and is written in C. +SWIFTFLAGS_EXTRAS = -gnone # The deployment target we set is pre-ABI stability. The Swift driver will not # point the RPATH at the system library. Do it manually. LD_EXTRAS := -Xlinker -rpath -Xlinker /usr/lib/swift -LD_EXTRAS += -L. -lPlaygroundsRuntime +LD_EXTRAS += -L. -lPlaygroundsRuntime -F. -framework AuxSources -PlaygroundStub: libPlaygroundsRuntime.dylib Dylib.framework +PlaygroundStub: libPlaygroundsRuntime.dylib Dylib.framework AuxSources.framework include Makefile.rules @@ -21,3 +23,10 @@ Dylib.framework: Dylib.swift DYLIB_SWIFT_SOURCES=Dylib.swift \ DYLIB_NAME=Dylib \ SWIFTFLAGS_EXTRAS="-Xcc -DNEW_OPTION_FROM_DYLIB=1" + +AuxSources.framework: AuxSources.swift + "$(MAKE)" -f $(MAKEFILE_RULES) \ + FRAMEWORK=AuxSources \ + DYLIB_SWIFT_SOURCES=AuxSources.swift \ + DYLIB_NAME=AuxSources \ + SWIFTFLAGS_EXTRAS="-Xcc -DHAVE_AUXSOURCES=1" diff --git a/lldb/test/API/lang/swift/playgrounds/PlaygroundStub.swift b/lldb/test/API/lang/swift/playgrounds/PlaygroundStub.swift index 532be511e6675..a98f115146c5a 100644 --- a/lldb/test/API/lang/swift/playgrounds/PlaygroundStub.swift +++ b/lldb/test/API/lang/swift/playgrounds/PlaygroundStub.swift @@ -11,8 +11,11 @@ // ----------------------------------------------------------------------------- @_silgen_name ("playground_logger_initialize") func builtin_initialize(); -@_silgen_name ("GetOutput") func get_output() -> String; builtin_initialize(); -print(""); // Set breakpoint here +func break_here() { + print("This is the frame where the playground expression will be executed.") +} + +break_here() diff --git a/lldb/test/API/lang/swift/playgrounds/TestSwiftPlaygrounds.py b/lldb/test/API/lang/swift/playgrounds/TestSwiftPlaygrounds.py index 7ec0a91f2d787..dfab500122478 100644 --- a/lldb/test/API/lang/swift/playgrounds/TestSwiftPlaygrounds.py +++ b/lldb/test/API/lang/swift/playgrounds/TestSwiftPlaygrounds.py @@ -119,8 +119,7 @@ def launch(self, force_target): ['libPlaygroundsRuntime.dylib']) # Set the breakpoints - breakpoint = target.BreakpointCreateBySourceRegex( - 'Set breakpoint here', lldb.SBFileSpec("PlaygroundStub.swift")) + breakpoint = target.BreakpointCreateByName('break_here') self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) process = target.LaunchSimple(None, None, os.getcwd()) @@ -147,7 +146,11 @@ def execute_code(self, input_file, expect_error=False): options.SetAutoApplyFixIts(False) res = self.frame().EvaluateExpression(contents, options) - ret = self.frame().EvaluateExpression("get_output()") + + options = lldb.SBExpressionOptions() + options.SetLanguage(lldb.eLanguageTypeSwift) + self.frame().EvaluateExpression("import PlaygroundsRuntime", options) + ret = self.frame().EvaluateExpression("get_output()", options) is_error = res.GetError().Fail() and not ( res.GetError().GetType() == 1 and res.GetError().GetError() == 0x1001) @@ -196,4 +199,9 @@ def do_import_test(self): # Scan through the types log to make sure the SwiftASTContext was poisoned. self.filecheck('platform shell cat ""%s"' % log, __file__) +# CHECK: RegisterSectionModules("AuxSources") +# CHECK: Playground : true +# If we wanted this to work, SwiftASTContext would need to find the AuxSources image and switch the symbol context to there. +# CHECK-NOT: -DHAVE_AUXSOURCES +# CHECK: Module import remark{{.*}} loaded module 'AuxSources'; source: 'AuxSources', loaded: 'AuxSources' # CHECK: New Swift image added{{.*}}Versions/A/Dylib{{.*}}ClangImporter needs to be reinitialized diff --git a/lldb/test/API/lang/swift/po/objc/Base.h b/lldb/test/API/lang/swift/po/objc/Base.h new file mode 100644 index 0000000000000..a3d2f698a1132 --- /dev/null +++ b/lldb/test/API/lang/swift/po/objc/Base.h @@ -0,0 +1,3 @@ +@import Foundation; +@interface Base : NSObject +@end diff --git a/lldb/test/API/lang/swift/po/objc/Foo.swift b/lldb/test/API/lang/swift/po/objc/Foo.swift new file mode 100644 index 0000000000000..63af93876e0db --- /dev/null +++ b/lldb/test/API/lang/swift/po/objc/Foo.swift @@ -0,0 +1,15 @@ +import Foundation +import Base + +private class Bar : Base { +} + +extension Bar { + override var debugDescription : String { "Hello from Swift" } +} + +@objc public class Foo : NSObject { + @objc public func getBase() -> Base? { + return Bar() + } +} diff --git a/lldb/test/API/lang/swift/po/objc/Makefile b/lldb/test/API/lang/swift/po/objc/Makefile new file mode 100644 index 0000000000000..c8045b88a604d --- /dev/null +++ b/lldb/test/API/lang/swift/po/objc/Makefile @@ -0,0 +1,9 @@ +OBJC_SOURCES := main.m +CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS) -I. -I$(BUILDDIR) + +SWIFT_SOURCES := Foo.swift +SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR) -emit-objc-header-path Foo.h -parse-as-library + +all: Foo.swift.o $(EXE) + +include Makefile.rules diff --git a/lldb/test/API/lang/swift/po/objc/TestSwiftPOObjC.py b/lldb/test/API/lang/swift/po/objc/TestSwiftPOObjC.py new file mode 100644 index 0000000000000..7939264e73d18 --- /dev/null +++ b/lldb/test/API/lang/swift/po/objc/TestSwiftPOObjC.py @@ -0,0 +1,27 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil + +class TestSwiftPOObjC(TestBase): + #NO_DEBUG_INFO_TESTCASE = True + @skipUnlessDarwin + @swiftTest + def test(self): + """Test running po on a Swift object from Objective-C. This + should initialize a generic SwiftASTContext with no parsing of + Swift modules happening""" + self.build() + + lldbutil.run_to_source_breakpoint( + self, "break here", lldb.SBFileSpec('main.m')) + + log = self.getBuildArtifact("types.log") + self.expect('log enable lldb types -f "%s"' % log) + self.expect("expr -O -- base", substrs=["Hello from Swift"]) + self.filecheck('platform shell cat "%s"' % log, __file__) +### -cc1 should be round-tripped so there is no more `-cc1` in the extra args. Look for `-triple` which is a cc1 flag. +# CHECK-NOT: parsed module "a" +# CHECK: SwiftASTContextForExpressions(module: "{{.*-.*-.*}}", cu: "*")::LogConfiguration() + self.expect("expr -- base", substrs=["a.Bar"]) + self.expect("expr -- *base", substrs=["a.Bar"]) diff --git a/lldb/test/API/lang/swift/po/objc/main.m b/lldb/test/API/lang/swift/po/objc/main.m new file mode 100644 index 0000000000000..95b8d0b1ccf55 --- /dev/null +++ b/lldb/test/API/lang/swift/po/objc/main.m @@ -0,0 +1,13 @@ +@import Foundation; +@import Base; +#import "Foo.h" + +@implementation Base +@end + +int main(int argc, char **argv) { + Foo *foo = [[Foo alloc] init]; + Base *base = [foo getBase]; + return 0; // break here + +} diff --git a/lldb/test/API/lang/swift/po/objc/module.modulemap b/lldb/test/API/lang/swift/po/objc/module.modulemap new file mode 100644 index 0000000000000..6b14c53a8a25d --- /dev/null +++ b/lldb/test/API/lang/swift/po/objc/module.modulemap @@ -0,0 +1 @@ +module Base { header "Base.h" } diff --git a/lldb/test/API/lang/swift/unit-tests/Info.plist b/lldb/test/API/lang/swift/unit-tests/Info.plist deleted file mode 100644 index b624baeff45a5..0000000000000 --- a/lldb/test/API/lang/swift/unit-tests/Info.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - CFExecutableName - test - - diff --git a/lldb/test/API/lang/swift/unit-tests/Makefile b/lldb/test/API/lang/swift/unit-tests/Makefile deleted file mode 100644 index cd208655b3f05..0000000000000 --- a/lldb/test/API/lang/swift/unit-tests/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -all: dylib xctest -C_SOURCES=xctest.c -EXE=xctest - -include Makefile.rules - -.PHONY: dylib -dylib: - "$(MAKE)" MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \ - ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ - VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk all - -clean:: - rm -rf *.o *.dSYM *.dylib *.swiftdoc *.swiftmodule *.xctest xctest - "$(MAKE)" VPATH=$(SRCDIR) -f $(SRCDIR)/dylib.mk clean - diff --git a/lldb/test/API/lang/swift/unit-tests/TestSwiftUnitTests.py b/lldb/test/API/lang/swift/unit-tests/TestSwiftUnitTests.py deleted file mode 100644 index 60b45ce4ad2ea..0000000000000 --- a/lldb/test/API/lang/swift/unit-tests/TestSwiftUnitTests.py +++ /dev/null @@ -1,31 +0,0 @@ -# TestSwiftUnitTests.py -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -# ------------------------------------------------------------------------------ -from lldbsuite.test.lldbtest import * -from lldbsuite.test.decorators import * -import lldbsuite.test.lldbutil as lldbutil - -class TestSwiftUnitTests(TestBase): - @skipUnlessDarwin - @swiftTest - # The creation of the .xctest framework messes with the AST search path. - @skipIf(debug_info=no_match("dsym")) - @skipIfDarwinEmbedded # swift crash inspecting swift stdlib with little other swift loaded - def test_cross_module_extension(self): - """Test that XCTest-based unit tests work""" - self.build() - lldbutil.run_to_source_breakpoint(self, - "Set breakpoint here", - lldb.SBFileSpec('xctest.c'), - exe_name = "xctest") - self.expect("expr -l Swift -- import test") - self.expect("expr -l Swift -- doTest()", - substrs=['Int','$R0','=','3']) diff --git a/lldb/test/API/lang/swift/unit-tests/dylib.mk b/lldb/test/API/lang/swift/unit-tests/dylib.mk deleted file mode 100644 index abd3ec70a5324..0000000000000 --- a/lldb/test/API/lang/swift/unit-tests/dylib.mk +++ /dev/null @@ -1,21 +0,0 @@ -all: UnitTest.xctest/Contents/MacOS/test UnitTest.xctest/Contents/Info.plist - -DYLIB_SWIFT_SOURCES := test.swift -DYLIB_NAME := test -DYLIB_ONLY := YES -include Makefile.rules - -UnitTest.xctest/Contents/MacOS/test: $(DYLIB_FILENAME) $(DSYM) - mkdir -p $(BUILDDIR)/UnitTest.xctest/Contents/MacOS - mv $(DYLIB_FILENAME) $(BUILDDIR)/UnitTest.xctest/Contents/MacOS/test -ifneq "$(MAKE_DSYM)" "NO" - mv $(DSYM)/Contents/Resources/DWARF/$(DYLIB_FILENAME) \ - $(DSYM)/Contents/Resources/DWARF/$(DYLIB_NAME) - mv $(DSYM) $(BUILDDIR)/UnitTest.xctest/Contents/MacOS/test.dSYM -endif - -UnitTest.xctest/Contents/Info.plist: Info.plist - cp $< $(BUILDDIR)/UnitTest.xctest/Contents/ - -clean:: - rm -rf *.o *.dSYM *.dylib *.swiftdoc *.swiftmodule *.xctest xctest diff --git a/lldb/test/API/lang/swift/unit-tests/test.swift b/lldb/test/API/lang/swift/unit-tests/test.swift deleted file mode 100644 index 7eabb3dae6a22..0000000000000 --- a/lldb/test/API/lang/swift/unit-tests/test.swift +++ /dev/null @@ -1,15 +0,0 @@ -// test.swift -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -// ----------------------------------------------------------------------------- - -public func doTest() -> Int { - return 3 -} diff --git a/lldb/test/API/lang/swift/unit-tests/xctest.c b/lldb/test/API/lang/swift/unit-tests/xctest.c deleted file mode 100644 index 217554f4a1d5b..0000000000000 --- a/lldb/test/API/lang/swift/unit-tests/xctest.c +++ /dev/null @@ -1,28 +0,0 @@ -//===-- xctest.c ----------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -#include -#include - -int main(int argc, const char **argv) { - char dylib[PATH_MAX]; - strlcpy(dylib, dirname(argv[0]), PATH_MAX); - strlcat(dylib, "/UnitTest.xctest/Contents/MacOS/test", PATH_MAX); - void *test_case = dlopen(dylib, RTLD_NOW); - - printf("%p\n", test_case); // Set breakpoint here - - return 0; -}