Skip to content
Open
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: 2 additions & 0 deletions test/Driver/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if not 'legacy_swift_driver' in config.available_features:
config.unsupported = True
44 changes: 44 additions & 0 deletions test/ModuleInterface/convenience-init-merge-module.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// REQUIRES: legacy_swift_driver
// RUN: %empty-directory(%t)

// Generate the parseable interface of the current file via the merge-modules step
// RUN: %target-build-swift -no-emit-module-separately -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s

// Make sure both don't add override for inits shadowing convenience initializers
// RUN: %FileCheck %s < %t/TestMerge.swiftinterface

// Check we can consume the interface without issue
// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface

public class Base {
let x: Int
public init(x: Int) {
self.x = x
}
convenience public init() {
self.init(x: 1)
}
}

public class Derived: Base {
// CHECK: {{^}} public init(z: Swift.Int)
public init(z: Int) {
super.init(x: z)
}
// CHECK: {{^}} public convenience init()
convenience public init() {
self.init(z: 1)
}
}

public class Derived2: Base {
// CHECK: {{^}} public init()
public init() {
super.init(x: 1)
}

// CHECK: {{^}} override public convenience init(x: Swift.Int)
override convenience public init(x: Int) {
self.init()
}
}
13 changes: 3 additions & 10 deletions test/ModuleInterface/convenience-init.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// RUN: %empty-directory(%t)

// Generate the parseable interface of the current file via the merge-modules step
// RUN: %target-build-swift -no-emit-module-separately -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s

// Generate the parseable interface of the current file via a single frontend invocation
// RUN: %target-swift-frontend -typecheck -enable-objc-interop -emit-module-interface-path %t/TestSingle.swiftinterface -module-name Test %s

// Make sure both don't add override for inits shadowing convenience initializers
// RUN: %FileCheck --check-prefixes=CHECK,SINGLE %s < %t/TestSingle.swiftinterface
// RUN: %FileCheck --check-prefixes=CHECK,MERGE %s < %t/TestMerge.swiftinterface
// RUN: %FileCheck --check-prefixes=CHECK %s < %t/TestSingle.swiftinterface

// Check we can consume the interface without issue
// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestSingle.swiftinterface
// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface

public class Base {
let x: Int
Expand All @@ -29,8 +24,7 @@ public class Derived: Base {
public init(z: Int) {
super.init(x: z)
}
// MERGE: {{^}} public convenience init()
// SINGLE: {{^}} convenience public init()
// CHECK: {{^}} convenience public init()
convenience public init() {
self.init(z: 1)
}
Expand All @@ -42,8 +36,7 @@ public class Derived2: Base {
super.init(x: 1)
}

// MERGE: {{^}} override public convenience init(x: Swift.Int)
// SINGLE: {{^}} override convenience public init(x: Swift.Int)
// CHECK: {{^}} override convenience public init(x: Swift.Int)
override convenience public init(x: Int) {
self.init()
}
Expand Down
85 changes: 85 additions & 0 deletions test/ModuleInterface/enums-layout-merge-module.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// REQUIRES: legacy_swift_driver
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -no-emit-module-separately -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface
// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib
// RUN: %target-swift-frontend -enable-objc-interop -O -emit-ir -primary-file %s -I %t -Xllvm -swiftmergefunc-threshold=0 | %FileCheck %s


import Lib

// CHECK-LABEL: define{{.+}}testFutureproofEnum
func testFutureproofEnum() -> FutureproofEnum {
// Check a few things in the function to make sure it's getting the case
// representation dynamically.
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib15FutureproofEnumO1byA2CmFWC"
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib15FutureproofEnumOMa"
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
// CHECK-NEXT: ret void
return .b
} // CHECK-NEXT: {{^}$}}

// CHECK-LABEL: define{{.+}}testFrozenEnum
func testFrozenEnum() -> FrozenEnum {
// CHECK: ret i8 1
return .b
} // CHECK-NEXT: {{^}$}}

// CHECK-LABEL: define{{.+}}testFutureproofObjCEnum
func testFutureproofObjCEnum() -> FutureproofObjCEnum {
// CHECK: ret i{{32|64}} 10
return .b
} // CHECK-NEXT: {{^}$}}

// CHECK-LABEL: define{{.+}}testFrozenObjCEnum
func testFrozenObjCEnum() -> FrozenObjCEnum {
// CHECK: ret i{{32|64}} 10
return .b
} // CHECK-NEXT: {{^}$}}

// CHECK-LABEL: define{{.+}}testFutureproofUnicodeScalarEnum
func testFutureproofUnicodeScalarEnum() -> FutureproofUnicodeScalarEnum {
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib28FutureproofUnicodeScalarEnumO1ayA2CmFWC"
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib28FutureproofUnicodeScalarEnumOMa"
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
// CHECK-NEXT: ret void
return .a
}

// CHECK-LABEL: define{{.+}}testFutureproofIndirectEnum
func testFutureproofIndirectEnum() -> FutureproofIndirectEnum {
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib23FutureproofIndirectEnumO1cyA2CmFWC"
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib23FutureproofIndirectEnumOMa"
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
// CHECK-NEXT: ret void
return .c
}

// CHECK-LABEL: define{{.+}}testFrozenIndirectEnum
func testFrozenIndirectEnum() -> FrozenIndirectEnum {
// Whether this is "1" or "2" depends on whether the reserved ObjC tagged
// pointer bit is the top or bottom bit on this platform.
// CHECK: ret i{{32|64}} {{1|2}}
return .c
}

// CHECK-LABEL: define{{.+}}testFutureproofIndirectCaseEnum
func testFutureproofIndirectCaseEnum() -> FutureproofIndirectCaseEnum {
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib27FutureproofIndirectCaseEnumO1cyA2CmFWC"
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib27FutureproofIndirectCaseEnumOMa"
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
// CHECK-NEXT: ret void
return .c
}

// CHECK-LABEL: define{{.+}}testFrozenIndirectCaseEnum
func testFrozenIndirectCaseEnum() -> FrozenIndirectCaseEnum {
// Whether this is "1" or "2" depends on whether the reserved ObjC tagged
// pointer bit is the top or bottom bit on this platform.
// CHECK: ret i{{32|64}} {{1|2}}
return .c
}
7 changes: 0 additions & 7 deletions test/ModuleInterface/enums-layout.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -no-emit-module-separately -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface
// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib
// RUN: %target-swift-frontend -enable-objc-interop -O -emit-ir -primary-file %s -I %t -Xllvm -swiftmergefunc-threshold=0 | %FileCheck %s

// Try again using a single-frontend build.
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -whole-module-optimization -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-SINGLE-FRONTEND %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface
// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib
Expand Down
6 changes: 3 additions & 3 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,11 @@ if not 'swift_driver' in lit_config.params:
config.available_features.add('swift_in_compiler')

# Check if we need to run lit tests using the legacy driver or the new driver
# The default for existing test runs is to use the legacy driver.
# The new driver is tested separately.
if os.environ.get('SWIFT_FORCE_TEST_NEW_DRIVER') is None:
# The default for existing test runs is to use the new driver.
if 'SWIFT_FORCE_TEST_OLD_DRIVER' in os.environ:
config.environment['SWIFT_USE_OLD_DRIVER'] = '1'
config.environment['SWIFT_AVOID_WARNING_USING_OLD_DRIVER'] = '1'
config.available_features.add('legacy_swift_driver')

# Enable benchmark testing when the binary is found (has fully qualified path).
if config.benchmark_o != 'Benchmark_O':
Expand Down