mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
70
test/ModuleInterface/Conformances.swiftinterface
Normal file
70
test/ModuleInterface/Conformances.swiftinterface
Normal file
@@ -0,0 +1,70 @@
|
||||
// swift-compiler-version: Swift 4.0
|
||||
// swift-module-flags:
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module-path %t/Conformances.swiftmodule -enable-library-evolution -emit-sil -o %t/Conformances.sil -enable-objc-interop -disable-objc-attr-requires-foundation-module %s
|
||||
// RUN: %FileCheck -check-prefix CHECK-MODULE %s < %t/Conformances.sil
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE-MODULE %s < %t/Conformances.sil
|
||||
// RUN: %target-swift-frontend -enable-objc-interop -emit-sil -I %t %S/Inputs/ConformancesUser.swift -O | %FileCheck %s
|
||||
|
||||
public protocol MyProto {
|
||||
init()
|
||||
func method()
|
||||
var prop: Int { get set }
|
||||
subscript(index: Int) -> Int { get set }
|
||||
}
|
||||
extension MyProto {
|
||||
public func method() {}
|
||||
}
|
||||
|
||||
// Make sure there's no default witness table. (But also make sure we printed at
|
||||
// least some regular witness tables, or we'll have to change the test.)
|
||||
// CHECK-MODULE: sil_witness_table{{.+}}: MyProto module Conformances
|
||||
// NEGATIVE-MODULE-NOT: sil_default_witness_table{{.+}}MyProto
|
||||
|
||||
|
||||
@frozen // allow conformance devirtualization
|
||||
public struct FullStructImpl: MyProto {
|
||||
public init()
|
||||
public func method()
|
||||
public var prop: Int { get set }
|
||||
public subscript(index: Int) -> Int { get set }
|
||||
}
|
||||
// CHECK-LABEL: sil @$s16ConformancesUser8testFullSiyF
|
||||
// CHECK: function_ref @$s12Conformances14FullStructImplVACycfC
|
||||
// CHECK: function_ref @$s12Conformances14FullStructImplV6methodyyF
|
||||
// CHECK: function_ref @$s12Conformances14FullStructImplV4propSivs
|
||||
// CHECK: function_ref @$s12Conformances14FullStructImplVyS2icig
|
||||
// CHECK: end sil function '$s16ConformancesUser8testFullSiyF'
|
||||
|
||||
@frozen // allow conformance devirtualization
|
||||
public struct OpaqueStructImpl: MyProto {}
|
||||
|
||||
// CHECK-LABEL: sil @$s16ConformancesUser10testOpaqueSiyF
|
||||
// CHECK: function_ref @$s12Conformances7MyProtoPxycfC
|
||||
// Note the default implementation is filled in here.
|
||||
// CHECK: function_ref @$s12Conformances7MyProtoPAAE6methodyyF
|
||||
// CHECK: function_ref @$s12Conformances7MyProtoP4propSivs
|
||||
// CHECK: function_ref @$s12Conformances7MyProtoPyS2icig
|
||||
// CHECK: end sil function '$s16ConformancesUser10testOpaqueSiyF'
|
||||
|
||||
|
||||
@objc public protocol OptionalReqs {
|
||||
@objc optional func method()
|
||||
}
|
||||
@_fixed_layout
|
||||
public final class OptionalReqsPresent: OptionalReqs {
|
||||
public func method () {}
|
||||
}
|
||||
@_fixed_layout
|
||||
public final class OptionalReqsAbsent: OptionalReqs {}
|
||||
|
||||
// It would be okay if this one got optimized...
|
||||
// CHECK-LABEL: sil @$s16ConformancesUser19testOptionalPresentySb0A00d4ReqsE0CF
|
||||
// CHECK: dynamic_method_br %0 : $OptionalReqsPresent, #OptionalReqs.method!1.foreign
|
||||
// CHECK: end sil function '$s16ConformancesUser19testOptionalPresentySb0A00d4ReqsE0CF'
|
||||
|
||||
// ...but not this one, because the method that's currently absent might get added.
|
||||
// CHECK-LABEL: sil @$s16ConformancesUser18testOptionalAbsentySb0A00d4ReqsE0CF
|
||||
// CHECK: dynamic_method_br %0 : $OptionalReqsAbsent, #OptionalReqs.method!1.foreign
|
||||
// CHECK: end sil function '$s16ConformancesUser18testOptionalAbsentySb0A00d4ReqsE0CF'
|
||||
25
test/ModuleInterface/DefaultArgs.swiftinterface
Normal file
25
test/ModuleInterface/DefaultArgs.swiftinterface
Normal file
@@ -0,0 +1,25 @@
|
||||
// swift-compiler-version: Swift 4.0
|
||||
// swift-module-flags:
|
||||
|
||||
// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
|
||||
|
||||
class SomeClass {
|
||||
// Has defaults, but no body.
|
||||
public func hasDefaults(a: Int = 4, b: Int = 1 + 2)
|
||||
|
||||
// CHECK-LABEL: sil hidden [ossa] @$s11DefaultArgs9SomeClassC11hasDefaults1a1bySi_SitFfA_
|
||||
// CHECK: integer_literal $Builtin.IntLiteral, 4
|
||||
// CHECK: end sil function '$s11DefaultArgs9SomeClassC11hasDefaults1a1bySi_SitFfA_'
|
||||
|
||||
// CHECK-LABEL: sil hidden [ossa] @$s11DefaultArgs9SomeClassC11hasDefaults1a1bySi_SitFfA0_
|
||||
// CHECK: integer_literal $Builtin.IntLiteral, 1
|
||||
// CHECK: integer_literal $Builtin.IntLiteral, 2
|
||||
// CHECK: function_ref @$sSi1poiyS2i_SitFZ
|
||||
// CHECK: end sil function '$s11DefaultArgs9SomeClassC11hasDefaults1a1bySi_SitFfA0_'
|
||||
|
||||
public init(a: Int = 5)
|
||||
|
||||
// CHECK-LABEL: sil hidden [ossa] @$s11DefaultArgs9SomeClassC1aACSi_tcfcfA_
|
||||
// CHECK: integer_literal $Builtin.IntLiteral, 5
|
||||
// CHECK: end sil function '$s11DefaultArgs9SomeClassC1aACSi_tcfcfA_'
|
||||
}
|
||||
29
test/ModuleInterface/Inputs/ConformancesUser.swift
Normal file
29
test/ModuleInterface/Inputs/ConformancesUser.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
import Conformances
|
||||
|
||||
func testGeneric<T: MyProto>(_: T.Type) -> Int {
|
||||
var impl = T.init()
|
||||
impl.method()
|
||||
impl.prop = 0
|
||||
return impl[0]
|
||||
}
|
||||
|
||||
public func testFull() -> Int {
|
||||
return testGeneric(FullStructImpl.self)
|
||||
}
|
||||
|
||||
public func testOpaque() -> Int {
|
||||
return testGeneric(OpaqueStructImpl.self)
|
||||
}
|
||||
|
||||
|
||||
func testOptionalGeneric<T: OptionalReqs>(_ obj: T) -> Bool {
|
||||
return obj.method?() != nil
|
||||
}
|
||||
|
||||
public func testOptionalPresent(_ obj: OptionalReqsPresent) -> Bool {
|
||||
return testOptionalGeneric(obj)
|
||||
}
|
||||
|
||||
public func testOptionalAbsent(_ obj: OptionalReqsAbsent) -> Bool {
|
||||
return testOptionalGeneric(obj)
|
||||
}
|
||||
3
test/ModuleInterface/Inputs/TestModule.swift
Normal file
3
test/ModuleInterface/Inputs/TestModule.swift
Normal file
@@ -0,0 +1,3 @@
|
||||
public struct TestStruct {
|
||||
public init() {}
|
||||
}
|
||||
115
test/ModuleInterface/Inputs/enums-layout-helper.swift
Normal file
115
test/ModuleInterface/Inputs/enums-layout-helper.swift
Normal file
@@ -0,0 +1,115 @@
|
||||
// CHECK-LABEL: public enum FutureproofEnum : Swift.Int
|
||||
public enum FutureproofEnum: Int {
|
||||
// CHECK-NEXT: case a{{$}}
|
||||
case a = 1
|
||||
// CHECK-NEXT: case b{{$}}
|
||||
case b = 10
|
||||
// CHECK-NEXT: case c{{$}}
|
||||
case c = 100
|
||||
// CHECK-NEXT: case d{{$}}
|
||||
case d
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FrozenEnum : Swift.Int
|
||||
@_frozen public enum FrozenEnum: Int {
|
||||
// CHECK-NEXT: case a{{$}}
|
||||
case a = 1
|
||||
// CHECK-NEXT: case b{{$}}
|
||||
case b = 10
|
||||
// CHECK-NEXT: case c{{$}}
|
||||
case c = 100
|
||||
// CHECK-NEXT: case d{{$}}
|
||||
case d
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FutureproofObjCEnum : Swift.Int32
|
||||
@objc public enum FutureproofObjCEnum: Int32 {
|
||||
// CHECK-NEXT: case a = 1{{$}}
|
||||
case a = 1
|
||||
// CHECK-NEXT: case b = 10{{$}}
|
||||
case b = 10
|
||||
// CHECK-NEXT: case c = 100{{$}}
|
||||
case c = 100
|
||||
// CHECK-NEXT: case d{{$}}
|
||||
case d
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FrozenObjCEnum : Swift.Int32
|
||||
@_frozen @objc public enum FrozenObjCEnum: Int32 {
|
||||
// CHECK-NEXT: case a = 1{{$}}
|
||||
case a = 1
|
||||
// CHECK-NEXT: case b = 10{{$}}
|
||||
case b = 10
|
||||
// CHECK-NEXT: case c = 100{{$}}
|
||||
case c = 100
|
||||
// CHECK-NEXT: case d{{$}}
|
||||
case d
|
||||
}
|
||||
|
||||
// CHECK-LABEL: indirect public enum FutureproofIndirectEnum
|
||||
public indirect enum FutureproofIndirectEnum {
|
||||
// CHECK-NEXT: case a{{$}}
|
||||
case a
|
||||
// CHECK-NEXT: case b(Swift.Int){{$}}
|
||||
case b(Int)
|
||||
// CHECK-NEXT: case c{{$}}
|
||||
case c
|
||||
}
|
||||
|
||||
// CHECK-LABEL: indirect public enum FrozenIndirectEnum
|
||||
@_frozen public indirect enum FrozenIndirectEnum {
|
||||
// CHECK-NEXT: case a{{$}}
|
||||
case a
|
||||
// CHECK-NEXT: case b(Swift.Int){{$}}
|
||||
case b(Int)
|
||||
// CHECK-NEXT: case c{{$}}
|
||||
case c
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FutureproofIndirectCaseEnum
|
||||
public enum FutureproofIndirectCaseEnum {
|
||||
// CHECK-NEXT: {{^}} case a{{$}}
|
||||
case a
|
||||
// CHECK-NEXT: indirect case b(Swift.Int){{$}}
|
||||
indirect case b(Int)
|
||||
// CHECK-NEXT: {{^}} case c{{$}}
|
||||
case c
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FutureproofIndirectMultiCaseEnum
|
||||
public enum FutureproofIndirectMultiCaseEnum {
|
||||
// CHECK-SINGLE-FRONTEND-NEXT: {{^}} case a1, a2{{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: {{^}} case a1{{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: {{^}} case a2{{$}}
|
||||
case a1, a2
|
||||
// CHECK-SINGLE-FRONTEND-NEXT: indirect case b1(Swift.Int), b2(Swift.Int){{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: indirect case b1(Swift.Int){{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: indirect case b2(Swift.Int){{$}}
|
||||
indirect case b1(Int), b2(Int)
|
||||
// CHECK-NEXT: {{^}} case c{{$}}
|
||||
case c
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FrozenIndirectCaseEnum
|
||||
@_frozen public enum FrozenIndirectCaseEnum {
|
||||
// CHECK-NEXT: {{^}} case a{{$}}
|
||||
case a
|
||||
// CHECK-NEXT: indirect case b(Swift.Int){{$}}
|
||||
indirect case b(Int)
|
||||
// CHECK-NEXT: {{^}} case c{{$}}
|
||||
case c
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public enum FrozenIndirectMultiCaseEnum
|
||||
@_frozen public enum FrozenIndirectMultiCaseEnum {
|
||||
// CHECK-SINGLE-FRONTEND-NEXT: {{^}} case a1, a2{{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: {{^}} case a1{{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: {{^}} case a2{{$}}
|
||||
case a1, a2
|
||||
// CHECK-SINGLE-FRONTEND-NEXT: indirect case b1(Swift.Int), b2(Swift.Int){{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: indirect case b1(Swift.Int){{$}}
|
||||
// CHECK-MULTI-FILE-NEXT: indirect case b2(Swift.Int){{$}}
|
||||
indirect case b1(Int), b2(Int)
|
||||
// CHECK-NEXT: {{^}} case c{{$}}
|
||||
case c
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#include <ExportAsCoreKit.h>
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef EXPORT_AS_COREKIT_H
|
||||
#define EXPORT_AS_COREKIT_H
|
||||
|
||||
struct CKThing {
|
||||
long value;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module CoreKit {
|
||||
header "CoreKit.h"
|
||||
header "ExportAsCoreKit.h"
|
||||
export *
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#include <ExportAsCoreKit.h>
|
||||
@@ -0,0 +1,3 @@
|
||||
struct CKThing {
|
||||
long value;
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
module CoreKit {
|
||||
header "CoreKit.h"
|
||||
export *
|
||||
}
|
||||
|
||||
module ExportAsCoreKit_BAD {
|
||||
header "ExportAsCoreKit.h"
|
||||
export_as CoreKit
|
||||
export *
|
||||
}
|
||||
17
test/ModuleInterface/Inputs/function_builders_client.swift
Normal file
17
test/ModuleInterface/Inputs/function_builders_client.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
import FunctionBuilders
|
||||
|
||||
let name = "dsl"
|
||||
tuplify(true) {
|
||||
17
|
||||
3.14159
|
||||
"Hello, \(name.map { $0.uppercased() }.joined())"
|
||||
do {
|
||||
["nested", "do"]
|
||||
1 + 2 + 3
|
||||
}
|
||||
if $0 {
|
||||
2.71828
|
||||
["if", "stmt"]
|
||||
}
|
||||
}
|
||||
|
||||
1
test/ModuleInterface/Inputs/imports-clang-modules/A.h
Normal file
1
test/ModuleInterface/Inputs/imports-clang-modules/A.h
Normal file
@@ -0,0 +1 @@
|
||||
void a(void);
|
||||
1
test/ModuleInterface/Inputs/imports-clang-modules/B1.h
Normal file
1
test/ModuleInterface/Inputs/imports-clang-modules/B1.h
Normal file
@@ -0,0 +1 @@
|
||||
void b1(void);
|
||||
1
test/ModuleInterface/Inputs/imports-clang-modules/B2.h
Normal file
1
test/ModuleInterface/Inputs/imports-clang-modules/B2.h
Normal file
@@ -0,0 +1 @@
|
||||
void b2(void);
|
||||
1
test/ModuleInterface/Inputs/imports-clang-modules/B3.h
Normal file
1
test/ModuleInterface/Inputs/imports-clang-modules/B3.h
Normal file
@@ -0,0 +1 @@
|
||||
void b2(void);
|
||||
1
test/ModuleInterface/Inputs/imports-clang-modules/C.h
Normal file
1
test/ModuleInterface/Inputs/imports-clang-modules/C.h
Normal file
@@ -0,0 +1 @@
|
||||
void c(void);
|
||||
1
test/ModuleInterface/Inputs/imports-clang-modules/D.h
Normal file
1
test/ModuleInterface/Inputs/imports-clang-modules/D.h
Normal file
@@ -0,0 +1 @@
|
||||
void d(void);
|
||||
@@ -0,0 +1 @@
|
||||
void notSoSecret(void);
|
||||
@@ -0,0 +1 @@
|
||||
void notSoSecret2(void);
|
||||
@@ -0,0 +1 @@
|
||||
void secret(void);
|
||||
@@ -0,0 +1,13 @@
|
||||
module A { header "A.h" }
|
||||
module B {
|
||||
explicit module B1 { header "B1.h" }
|
||||
explicit module B2 { header "B2.h" }
|
||||
explicit module B3 { header "B3.h" }
|
||||
}
|
||||
module C { header "C.h" }
|
||||
module D { header "D.h" }
|
||||
|
||||
module Secret_BAD { header "Secret_BAD.h" }
|
||||
|
||||
module NotSoSecret { header "NotSoSecret.h" }
|
||||
module NotSoSecret2 { header "NotSoSecret2.h" }
|
||||
6
test/ModuleInterface/Inputs/imports-other.swift
Normal file
6
test/ModuleInterface/Inputs/imports-other.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
import A
|
||||
import B.B3
|
||||
import D
|
||||
|
||||
import NotSoSecret // expected-warning {{'NotSoSecret' inconsistently imported as implementation-only}}
|
||||
@_implementationOnly import NotSoSecret2 // expected-note {{imported as implementation-only here}}
|
||||
@@ -0,0 +1,7 @@
|
||||
module X {
|
||||
explicit module Submodule {}
|
||||
}
|
||||
|
||||
module Y {
|
||||
explicit module Submodule {}
|
||||
}
|
||||
36
test/ModuleInterface/Inputs/make-unreadable.py
Normal file
36
test/ModuleInterface/Inputs/make-unreadable.py
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
import ctypes
|
||||
AdvAPI32 = ctypes.windll.Advapi32
|
||||
|
||||
from ctypes.wintypes import POINTER
|
||||
|
||||
UNLEN = 256
|
||||
|
||||
GetUserNameW = AdvAPI32.GetUserNameW
|
||||
GetUserNameW.argtypes = (
|
||||
ctypes.c_wchar_p, # _In_Out_ lpBuffer
|
||||
POINTER(ctypes.c_uint) # _In_out_ pcBuffer
|
||||
)
|
||||
GetUserNameW.restype = ctypes.c_uint
|
||||
|
||||
buffer = ctypes.create_unicode_buffer(UNLEN + 1)
|
||||
size = ctypes.c_uint(len(buffer))
|
||||
GetUserNameW(buffer, ctypes.byref(size))
|
||||
# For NetworkService, Host$ is returned, so we choose have to turn it back
|
||||
# into something that icacls understands.
|
||||
if not buffer.value.endswith('$'):
|
||||
user_name = buffer.value
|
||||
else:
|
||||
user_name = 'NT AUTHORITY\\NetworkService'
|
||||
|
||||
for path in sys.argv[1:]:
|
||||
subprocess.call(['icacls', path, '/deny',
|
||||
'{}:(R)'.format(user_name)])
|
||||
else:
|
||||
for path in sys.argv[1:]:
|
||||
subprocess.call(['chmod', 'a-r', path])
|
||||
63
test/ModuleInterface/Inputs/opaque-result-types-client.swift
Normal file
63
test/ModuleInterface/Inputs/opaque-result-types-client.swift
Normal file
@@ -0,0 +1,63 @@
|
||||
import OpaqueResultTypes
|
||||
|
||||
func getAssocType<T: AssocTypeInference>(_ x: T) -> T.Assoc {
|
||||
return x.foo(0)
|
||||
}
|
||||
func getAssocPropType<T: AssocTypeInference>(_ x: T) -> T.AssocProperty {
|
||||
return x.prop
|
||||
}
|
||||
func getAssocSubscriptType<T: AssocTypeInference>(_ x: T) -> T.AssocSubscript {
|
||||
return x[]
|
||||
}
|
||||
|
||||
struct MyFoo: Foo {}
|
||||
struct YourFoo: Foo {}
|
||||
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
func someTypeIsTheSame() {
|
||||
var a = foo(0)
|
||||
a = foo(0)
|
||||
a = foo("") // expected-error{{cannot assign}}
|
||||
|
||||
var b = foo("")
|
||||
b = foo(0) // expected-error{{cannot assign}}
|
||||
b = foo("")
|
||||
|
||||
var c = foo(MyFoo())
|
||||
c = foo(0) // expected-error{{cannot assign}}
|
||||
c = foo(MyFoo())
|
||||
c = foo(YourFoo()) // expected-error{{cannot assign}}
|
||||
|
||||
var barInt = Bar<Int>()
|
||||
var barString = Bar<String>()
|
||||
|
||||
var d = barInt.foo(0)
|
||||
d = barInt.foo(0)
|
||||
d = barString.foo(0) // expected-error{{cannot assign}}
|
||||
d = getAssocType(barInt)
|
||||
d = getAssocType(barString) // expected-error{{cannot assign}}
|
||||
|
||||
var d2 = barInt.prop
|
||||
d2 = barInt.prop
|
||||
d2 = barString.prop // expected-error{{cannot assign}}
|
||||
d2 = getAssocPropType(barInt)
|
||||
d2 = getAssocPropType(barString) // expected-error{{cannot assign}}
|
||||
|
||||
var d3 = barInt[]
|
||||
d3 = barInt[]
|
||||
d3 = barString[] // expected-error{{cannot assign}}
|
||||
d3 = getAssocSubscriptType(barInt)
|
||||
d3 = getAssocSubscriptType(barString) // expected-error{{cannot assign}}
|
||||
|
||||
var e = barString.foo(0)
|
||||
e = barInt.foo(0) // expected-error{{cannot assign}}
|
||||
e = barString.foo(0)
|
||||
e = getAssocType(barInt) // expected-error{{cannot assign}}
|
||||
e = getAssocType(barString)
|
||||
|
||||
var f = barInt.foo(MyFoo())
|
||||
f = barInt.foo(MyFoo())
|
||||
f = barString.foo(MyFoo()) // expected-error{{cannot assign}}
|
||||
f = barInt.foo(YourFoo()) // expected-error{{cannot assign}}
|
||||
f = barString.foo(MyFoo()) // expected-error{{cannot assign}}
|
||||
}
|
||||
1
test/ModuleInterface/Inputs/other.swift
Normal file
1
test/ModuleInterface/Inputs/other.swift
Normal file
@@ -0,0 +1 @@
|
||||
public func otherFileFunction() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
for input_path in sys.argv[1:]:
|
||||
with open(input_path, 'r') as yaml_file:
|
||||
# Forwarding files are YAML files that start with '---'
|
||||
if yaml_file.read(3) != '---':
|
||||
print("swiftmodule '%s' is not a forwarding module!" % input_path)
|
||||
sys.exit(1)
|
||||
27
test/ModuleInterface/ModuleCache/Inputs/check-is-new.py
Executable file
27
test/ModuleInterface/ModuleCache/Inputs/check-is-new.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# check-is-new.py - a more-legible way to read a timestamp test than test(1)
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Compares the mtime of the provided files to a constant "old" reference time.
|
||||
# Fails if any file is as-old-or-older than old.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
OLD = 1390550700 # 2014-01-24T08:05:00+00:00
|
||||
for f in sys.argv[1:]:
|
||||
if os.stat(f).st_mtime <= OLD:
|
||||
print("%s is not new!" % f)
|
||||
exit(1)
|
||||
27
test/ModuleInterface/ModuleCache/Inputs/check-is-old.py
Executable file
27
test/ModuleInterface/ModuleCache/Inputs/check-is-old.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# check-is-old.py - a more-legible way to read a timestamp test than test(1)
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Compares the mtime of the provided files to a constant "old" reference time.
|
||||
# Fails if any file has mtime not-equal to old.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
OLD = 1390550700 # 2014-01-24T08:05:00+00:00
|
||||
for f in sys.argv[1:]:
|
||||
if os.stat(f).st_mtime != OLD:
|
||||
print("%s is not old!" % f)
|
||||
exit(1)
|
||||
@@ -0,0 +1,9 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name Lib
|
||||
|
||||
public struct FromInterface {
|
||||
@inlinable public init() {}
|
||||
}
|
||||
public var testValue: FromInterface {
|
||||
@inlinable get { return FromInterface() }
|
||||
}
|
||||
24
test/ModuleInterface/ModuleCache/Inputs/make-old.py
Executable file
24
test/ModuleInterface/ModuleCache/Inputs/make-old.py
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# make-old.py - /bin/touch that writes a constant "old" timestamp.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Like /bin/touch, but writes a constant "old" timestamp.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
OLD = 1390550700 # 2014-01-24T08:05:00+00:00
|
||||
for f in sys.argv[1:]:
|
||||
os.utime(f, (OLD, OLD))
|
||||
@@ -0,0 +1,11 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name ExportedLib
|
||||
|
||||
@_exported import SomeCModule
|
||||
|
||||
public struct ExportedInterface {
|
||||
@inlinable public init() {}
|
||||
}
|
||||
public var testValue: ExportedInterface {
|
||||
@inlinable get { return ExportedInterface() }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name SdkLib
|
||||
|
||||
@_exported import ExportedLib
|
||||
|
||||
public var testValue2: ExportedInterface {
|
||||
@inlinable get { return ExportedInterface() }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
extern int x;
|
||||
@@ -0,0 +1,3 @@
|
||||
module SomeCModule {
|
||||
header "SomeCModule.h"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name Lib
|
||||
|
||||
public struct FromInterface {
|
||||
@inlinable public init() {}
|
||||
}
|
||||
public var testValue: FromInterface {
|
||||
@inlinable get { return FromInterface() }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name LibExporter
|
||||
|
||||
@_exported import Lib
|
||||
@@ -0,0 +1,10 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name ObjCAttrWithoutFoundation -enable-library-evolution -enable-objc-interop
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'import ObjCAttrWithoutFoundation' | %target-swift-frontend -typecheck -module-cache-path %t -I %S -
|
||||
|
||||
public class MyClass {
|
||||
public init()
|
||||
@objc deinit
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
// RUN: %empty-directory(%t/PrebuiltCache)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Create an empty .swiftmodule, which will force recompiling from the interface
|
||||
// RUN: touch %t/Build/TestModule.swiftmodule
|
||||
|
||||
// 4. Try to import the malformed compiled module
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{is out of date}}
|
||||
// expected-note @-2 {{malformed}}
|
||||
@@ -0,0 +1,31 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create both an interface and a compiled module for it
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/Build/TestModule.swiftmodule %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5 -module-name TestModule
|
||||
|
||||
// 3. Make the compiled module unreadable so it gets added as a dependency but is not used
|
||||
// RUN: mv %t/Build/TestModule.swiftmodule %t/Build/TestModule.swiftmodule.moved-aside
|
||||
// RUN: echo 'this is unreadable' > %t/Build/TestModule.swiftmodule
|
||||
|
||||
// 4. Try to import the module, which will create a cached module that depends on both the .swiftmodule and .swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -module-cache-path %t/ModuleCache
|
||||
|
||||
// 5. Remove the .swiftmodule, which will result in a missing dependency note
|
||||
// RUN: rm %t/Build/TestModule.swiftmodule
|
||||
|
||||
// 6. Rebuild with remarks enabled, make sure the missing dependency note is emitted
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
// 7. Put the module back, make the interface unreadable, and make sure the compiler succeeds
|
||||
// RUN: mv %t/Build/TestModule.swiftmodule.moved-aside %t/Build/TestModule.swiftmodule
|
||||
// RUN: mv %t/Build/TestModule.swiftinterface %t/Build/TestModule.swiftinterface.moved-aside
|
||||
// RUN: echo 'this is unreadable' > %t/Build/TestModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{cached module is out of date}}
|
||||
// expected-note @-2 {{dependency is missing}}
|
||||
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Try to import the interface, which will pass and create a cached module
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -module-cache-path %t/ModuleCache
|
||||
|
||||
// 3a. Make sure the test works on a fast machine
|
||||
// RUN: sleep 1
|
||||
|
||||
// 4. Touch the interface so the cached module is no longer up-to-date
|
||||
// RUN: %{python} %S/../Inputs/make-old.py %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 5. Try to import the now out-of-date cached module
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{cached module is out of date}}
|
||||
// expected-note @-2 {{dependency is out of date}}
|
||||
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Build the .swiftinterface to a .swiftmodule, which will have a dependency on the interface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/Build/TestModule.swiftmodule %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 3a. Make sure the test works on a fast machine
|
||||
// RUN: sleep 1
|
||||
|
||||
// 4. Touch the interface so the module is no longer up-to-date
|
||||
// RUN: %{python} %S/../Inputs/make-old.py %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 5. Try to import the out-of-date compiled module
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{compiled module is out of date}}
|
||||
// expected-note @-2 {{dependency is out of date}}
|
||||
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
// RUN: %empty-directory(%t/PrebuiltCache)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Build the .swiftinterface to a .swiftmodule in the prebuilt cache, which will have a dependency on the interface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Build/TestModule.swiftinterface -o %t/PrebuiltCache/TestModule.swiftmodule
|
||||
|
||||
// 5. Try to import the prebuilt module (this should pass)
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -sdk %t -prebuilt-module-cache-path %t/PrebuiltCache -module-cache-path %t/ModuleCache
|
||||
|
||||
// 6. Make sure we installed a forwarding module in the cache
|
||||
// RUN: %{python} %S/../Inputs/check-is-forwarding-module.py %t/ModuleCache/TestModule-*.swiftmodule
|
||||
|
||||
// 7. Modify the interface so the forwarding module and prebuilt modules are no longer up-to-date
|
||||
// RUN: echo ' ' >> %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 8. Try to import the now out-of-date forwarding module, which will fail.
|
||||
// It will also fail to load the prebuilt module after the forwarding module
|
||||
// is rejected, meaning we'll get a second set of notes about the prebuilt module.
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -sdk %t -prebuilt-module-cache-path %t/PrebuiltCache -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{forwarding module is out of date}}
|
||||
// expected-note @-2 {{dependency is out of date}}
|
||||
// expected-note @-3 {{prebuilt module is out of date}}
|
||||
// expected-note @-4 {{dependency is out of date}}
|
||||
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
|
||||
// 1. Create a module called InnerModule, and put its interface into the build dir.
|
||||
// RUN: echo 'public func inInnerModule() {}' | %target-swift-frontend - -typecheck -emit-module-interface-path %t/Build/InnerModule.swiftinterface -enable-library-evolution -swift-version 5 -module-name InnerModule
|
||||
|
||||
// 2. Build the .swiftinterface to a .swiftmodule, which will have a dependency on the interface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/Build/InnerModule.swiftmodule %t/Build/InnerModule.swiftinterface
|
||||
|
||||
// 3. Touch the interface so the module becomes out of date.
|
||||
// RUN: %{python} %S/../Inputs/make-old.py %t/Build/InnerModule.swiftinterface
|
||||
|
||||
// 4. Create a module called OuterModule that imports InnerModule, and put its interface into the build dir.
|
||||
// RUN: echo 'import InnerModule' | %target-swift-frontend - -emit-module -o %t/Build/OuterModule.swiftmodule -module-name OuterModule -I %t/Build
|
||||
|
||||
// 5. Build this file, and expect that InnerModule is out of date
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache 2>&1 | %FileCheck %s
|
||||
|
||||
import OuterModule
|
||||
|
||||
// CHECK: rebuilding module 'InnerModule' from interface '{{.*}}{{[/\\]}}Build{{[/\\]}}InnerModule.swiftinterface'
|
||||
// CHECK: compiled module is out of date: '{{.*}}{{[/\\]}}Build{{[/\\]}}InnerModule.swiftmodule'
|
||||
// CHECK: dependency is out of date: '{{.*}}{{[/\\]}}Build{{[/\\]}}InnerModule.swiftinterface'
|
||||
@@ -0,0 +1,192 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1) Build a prebuilt cache for our SDK
|
||||
//
|
||||
// RUN: mkdir %t/MCP %t/prebuilt-cache %t/my-sdk
|
||||
// RUN: cp -r %S/Inputs/mock-sdk/. %t/my-sdk
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
//
|
||||
// Check the prebuilt modules don't contain dependencies in the module cache, prebuilt cache, or resource dir
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// PREBUILT: MODULE_BLOCK
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]MCP[/\\]}}
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]prebuilt-cache[/\\]}}
|
||||
// PREBUILD-NOT: FILE_DEPENDENCY {{.*[/\\]lib[/\\]swift[/\\]}}
|
||||
//
|
||||
// Re-build them in the opposite order
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
//
|
||||
// Check they still don't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '1: PASSED'
|
||||
|
||||
|
||||
// 2) Baseline check: Make sure we use the interface when not passing the prebuilt module cache path
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check they are *not* forwarding modules
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they don't contain dependencies in the module cache (..or prebuilt cache)
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
//
|
||||
// DEPFILE-DAG: SomeCModule.h
|
||||
// DEPFILE-DAG: SdkLib.swiftinterface
|
||||
// DEPFILE-DAG: ExportedLib.swiftinterface
|
||||
// DEPFILE-DAG: SDKDependencies-disable-validation.swift
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '2: PASSED'
|
||||
|
||||
|
||||
// 3) Baseline check: Make sure we use the the prebuilt module cache when using the SDK it was built with
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they *are* forwarding modules
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they contain the expected dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefixes=EXLIB,SDKLIB
|
||||
//
|
||||
// EXLIB: dependencies:
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}module.modulemap'
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}SomeCModule.h'
|
||||
// EXLIB-DAG: path: ExportedLib.swiftinterface
|
||||
// SDKLIB-DAG: SdkLib.swiftinterface
|
||||
//
|
||||
// Check they don't contain any dependencies from either cache other than themselves
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
|
||||
//
|
||||
// NOCACHE: dependencies:
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// NOCACHE: {{[/\\]prebuilt-cache[/\\]}}[[LIB_NAME]].swiftmodule
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: echo '3: PASSED'
|
||||
|
||||
|
||||
// 4) Now change the SDK's content WITHOUT clearing the module cache and check
|
||||
// that it doesn't change anything...
|
||||
//
|
||||
// RUN: echo "// size change" >> %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check that they're both still forwarding modules, because we didn't stat
|
||||
// the system dependencies.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib still contains the same dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
//
|
||||
// RUN: echo '4: PASSED'
|
||||
|
||||
// 5) ...but if we clear the module cache and start over, we won't be using the
|
||||
// prebuilt module anymore for SDKLib.
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib still contains the same dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
//
|
||||
// Check SdkLib doesn't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: echo '5: PASSED'
|
||||
|
||||
// 6) If we do one more change, we won't rebuild SdkLib *again*...
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: echo "// size change" >> %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check SdkLib hasn't been rebuilt.
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// RUN: echo '6: PASSED'
|
||||
|
||||
// 7) ...until we turn off -disable-modules-validate-system-headers.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: echo "// size change" >> %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check SdkLib has been rebuilt.
|
||||
// RUN: not %{python} %S/Inputs/check-is-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// RUN: echo '7: PASSED'
|
||||
|
||||
|
||||
import SdkLib
|
||||
|
||||
func foo() -> ExportedInterface {
|
||||
return x > 3 ? testValue : testValue2
|
||||
}
|
||||
208
test/ModuleInterface/ModuleCache/SDKDependencies.swift
Normal file
208
test/ModuleInterface/ModuleCache/SDKDependencies.swift
Normal file
@@ -0,0 +1,208 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1) Build a prebuilt cache for our SDK
|
||||
//
|
||||
// RUN: mkdir %t/MCP %t/prebuilt-cache %t/my-sdk
|
||||
// RUN: cp -r %S/Inputs/mock-sdk/. %t/my-sdk
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
//
|
||||
// Check the prebuilt modules don't contain dependencies in the module cache, prebuilt cache, or resource dir
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// PREBUILT: MODULE_BLOCK
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]MCP[/\\]}}
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]prebuilt-cache[/\\]}}
|
||||
// PREBUILD-NOT: FILE_DEPENDENCY {{.*[/\\]lib[/\\]swift[/\\]}}
|
||||
//
|
||||
// Re-build them in the opposite order
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
//
|
||||
// Check they still don't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '1: PASSED'
|
||||
|
||||
|
||||
// 2) Baseline check: Make sure we use the interface when not passing the prebuilt module cache path
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check they are *not* forwarding modules
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they don't contain dependencies in the module cache (..or prebuilt cache)
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
//
|
||||
// DEPFILE-DAG: SomeCModule.h
|
||||
// DEPFILE-DAG: SdkLib.swiftinterface
|
||||
// DEPFILE-DAG: ExportedLib.swiftinterface
|
||||
// DEPFILE-DAG: SDKDependencies.swift
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '2: PASSED'
|
||||
|
||||
|
||||
// 3) Baseline check: Make sure we use the the prebuilt module cache when using the SDK it was built with
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they *are* forwarding modules
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they contain the expected dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefixes=EXLIB,SDKLIB
|
||||
//
|
||||
// EXLIB: dependencies:
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}module.modulemap'
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}SomeCModule.h'
|
||||
// EXLIB-DAG: path: ExportedLib.swiftinterface
|
||||
// SDKLIB-DAG: SdkLib.swiftinterface
|
||||
//
|
||||
// Check they don't contain any dependencies from either cache other than themselves
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
|
||||
//
|
||||
// NOCACHE: dependencies:
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// NOCACHE: {{[/\\]prebuilt-cache[/\\]}}[[LIB_NAME]].swiftmodule
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '3: PASSED'
|
||||
|
||||
|
||||
// 4) Move the SDK without changing its contents
|
||||
//
|
||||
// RUN: mv %t/my-sdk %t/my-new-sdk
|
||||
// RUN: mkdir %t/new-dir
|
||||
// RUN: mv %t/prebuilt-cache %t/new-dir/
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they are still both forwarding modules
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they contain the expected dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NEW-EXLIB
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefixes=NEW-EXLIB,NEW-SDKLIB
|
||||
//
|
||||
// NEW-EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}module.modulemap'
|
||||
// NEW-EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}SomeCModule.h'
|
||||
// NEW-EXLIB-DAG: path: ExportedLib.swiftinterface
|
||||
// NEW-SDKLIB-DAG: path: SdkLib.swiftinterface
|
||||
//
|
||||
// Check they don't contain dependencies from the module cache, old prebuilt
|
||||
// cache, or new prebuilt cache
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '4: PASSED'
|
||||
|
||||
|
||||
// 5) Now change the SDK's content and check it no longer uses the prebuilt modules
|
||||
//
|
||||
// RUN: echo "// size change" >> %t/my-new-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib still contains the same dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NEW-EXLIB
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
//
|
||||
// Check SdkLib doesn't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
//
|
||||
// RUN: echo "// size change" >> %t/my-new-sdk/usr/include/SomeCModule.h
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SDKLib and ExportLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check neither are forwarding modules
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check neither contains dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: echo '5: PASSED'
|
||||
|
||||
|
||||
// 6) Keeping the existing cache, update ExportedLib to no longer depend on SomeCModule
|
||||
//
|
||||
// RUN: grep -v import %t/my-new-sdk/ExportedLib.swiftinterface > %t/my-new-sdk/ExportedLib.swiftinterface.updated
|
||||
// RUN: mv %t/my-new-sdk/ExportedLib.swiftinterface.updated %t/my-new-sdk/ExportedLib.swiftinterface
|
||||
//
|
||||
// RUN: sed -e 's/x > 3/5 > 3/g' %s | %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -
|
||||
//
|
||||
// Check we don't have SomeCModule listed in dependencies
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefixes=DEPFILE-NEGATIVE,DEPCHANGE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPCHANGE
|
||||
//
|
||||
// DEPCHANGE-NEGATIVE-NOT: SomeCModule.h
|
||||
//
|
||||
// DEPCHANGE-DAG: SdkLib.swiftinterface
|
||||
// DEPCHANGE-DAG: ExportedLib.swiftinterface
|
||||
// DEPCHANGE-DAG: SDKDependencies.swift
|
||||
|
||||
import SdkLib
|
||||
|
||||
func foo() -> ExportedInterface {
|
||||
return x > 3 ? testValue : testValue2
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name SerializedSIL -enable-library-evolution
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'import SerializedSIL' | %target-swift-frontend -typecheck -module-cache-path %t -I %S -
|
||||
// RUN: %target-sil-opt -disable-sil-linking %t/SerializedSIL-*.swiftmodule -module-name SerializedSIL > %t/SerializedSIL.sil
|
||||
// RUN: %FileCheck %s < %t/SerializedSIL.sil
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/SerializedSIL.sil
|
||||
|
||||
public class TestClass {
|
||||
public init()
|
||||
public func method()
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
public var prop: Int { get set }
|
||||
public var storedProp: Int
|
||||
public static var staticProp: Int
|
||||
deinit
|
||||
}
|
||||
|
||||
public class TestEmptyClass {
|
||||
}
|
||||
|
||||
public struct TestEmptyStruct {
|
||||
}
|
||||
|
||||
public enum TestEnum {
|
||||
case a
|
||||
public init()
|
||||
public func method()
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
public var prop: Int { get set }
|
||||
public static var staticProp: Int
|
||||
}
|
||||
|
||||
public struct TestStruct {
|
||||
public init()
|
||||
public func method()
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
public var prop: Int { get set }
|
||||
public var storedProp: Int
|
||||
public static var staticProp: Int
|
||||
}
|
||||
|
||||
public let globalWithNoAccessors: Int
|
||||
public var readOnlyVar: Int { get }
|
||||
public var readWriteVar: Int { get set }
|
||||
public func verySimpleFunction()
|
||||
|
||||
// CHECK: sil [serialized] [exact_self_class] [canonical] @$s13SerializedSIL9TestClassCACycfC : $@convention(method) (@thick TestClass.Type) -> @owned TestClass {
|
||||
|
||||
// NEGATIVE-NOT: {{sil .*@.+storedProp}}
|
||||
|
||||
// NEGATIVE-NOT: sil_vtable
|
||||
// NEGATIVE-NOT: sil_witness_table
|
||||
@@ -0,0 +1,55 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name SystemDependencies
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: cp -r %S/Inputs/mock-sdk %t/mock-sdk
|
||||
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
|
||||
// RUN: test -f %t/MCP/SystemDependencies*.swiftmodule
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/dummy.d
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SystemDependencies*.swiftmodule
|
||||
|
||||
// Baseline: running the same command again doesn't rebuild the cached module.
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SystemDependencies*.swiftmodule
|
||||
|
||||
// Now try changing the contents.
|
||||
// RUN: echo "// size change" >> %t/mock-sdk/usr/include/SomeCModule.h
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SystemDependencies*.swiftmodule
|
||||
|
||||
// Okay, now let's try again with system dependency tracking on.
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
|
||||
// RUN: test -f %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
// RUN: %FileCheck -check-prefix CHECK %s < %t/dummy.d
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP-system/SystemDependencies*.swiftmodule | %FileCheck -check-prefix CHECK-DUMP %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
|
||||
// Baseline: running the same command again doesn't rebuild the cached module.
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
|
||||
// Now try changing the contents.
|
||||
// RUN: echo "// size change" >> %t/mock-sdk/usr/include/SomeCModule.h
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
|
||||
// Check that it picked a different cache key.
|
||||
// RUN: %empty-directory(%t/MCP-combined)
|
||||
// RUN: cp %t/MCP/SystemDependencies*.swiftmodule %t/MCP-combined
|
||||
// RUN: cp %t/MCP-system/SystemDependencies*.swiftmodule %t/MCP-combined
|
||||
// RUN: ls -1 %t/MCP-combined | %FileCheck %s -check-prefix=MODULECACHE
|
||||
|
||||
// NEGATIVE-NOT: SomeCModule.h
|
||||
// CHECK: SomeCModule.h
|
||||
|
||||
// CHECK-DUMP-NOT: usr{{[/\\]}}include
|
||||
// CHECK-DUMP: DEPENDENCY_DIRECTORY{{.+}}'usr{{[/\\]}}include'
|
||||
// CHECK-DUMP-NEXT: FILE_DEPENDENCY{{.+}}'module.modulemap'
|
||||
// CHECK-DUMP-NOT: FILE_DEPENDENCY{{.+}}'SomeCModule.h'
|
||||
// CHECK-DUMP: FILE_DEPENDENCY{{.+}}'SomeCModule.h'
|
||||
// CHECK-DUMP-NOT: usr{{[/\\]}}include
|
||||
|
||||
// MODULECACHE-COUNT-2: SystemDependencies-{{[^ ]+}}.swiftmodule
|
||||
|
||||
import SomeCModule
|
||||
@@ -0,0 +1,7 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name DreadPirateRoberts
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'import WrongName' | not %target-swift-frontend -typecheck -module-cache-path %t -I %S - 2>&1 | %FileCheck %s
|
||||
|
||||
// CHECK: :1:8: error: cannot load module 'DreadPirateRoberts' as 'WrongName'
|
||||
@@ -0,0 +1,3 @@
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=garbage not %target-swift-frontend -typecheck %s 2>&1 | %FileCheck %s
|
||||
|
||||
// CHECK: error: unknown value for SWIFT_FORCE_MODULE_LOADING variable: 'garbage'
|
||||
@@ -0,0 +1,102 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1. Not finding things is okay.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
// 2. Only interface is present.
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 3. Only module is present.
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromSerialized/g' %S/Inputs/force-module-loading-mode/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/Lib.swiftmodule/%target-swiftmodule-name - -module-name Lib
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 4. Both are present.
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 5. Both are present but the module is invalid.
|
||||
// RUN: rm %t/Lib.swiftmodule/%target-swiftmodule-name && touch %t/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=BAD-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 6. Both are present but the module can't be opened.
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 7. Both are present but for the wrong architecture.
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: touch %t/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: touch %t/Lib.swiftmodule/garbage.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
|
||||
// 8. Only the interface is present but for the wrong architecture.
|
||||
// (Diagnostics for the module only are tested elsewhere.)
|
||||
// FIXME: We should improve this to not just say NO-SUCH-MODULE.
|
||||
// RUN: rm %t/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
import Lib
|
||||
// NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib'
|
||||
// BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule
|
||||
// WRONG-ARCH: [[@LINE-3]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: garbage
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-SERIALIZED: [[@LINE-2]]:16: error: cannot convert value of type 'FromSerialized' to specified type 'X'
|
||||
@@ -0,0 +1,103 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1. Not finding things is okay.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
// 2. Only interface is present.
|
||||
// RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 3. Only module is present.
|
||||
// RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromSerialized/g' %S/Inputs/force-module-loading-mode/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name - -module-name Lib
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
|
||||
// 4. Both are present.
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 5. Both are present but the module is invalid.
|
||||
// RUN: rm %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name && touch %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=BAD-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 6. Both are present but the module can't be opened.
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 7. Both are present but for the wrong architecture.
|
||||
// RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: touch %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: touch %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
|
||||
// 8. Only the interface is present but for the wrong architecture.
|
||||
// (Diagnostics for the module only are tested elsewhere.)
|
||||
// FIXME: We should improve this to not just say NO-SUCH-MODULE.
|
||||
// RUN: rm %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
import Lib
|
||||
// NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib'
|
||||
// BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule
|
||||
// WRONG-ARCH: [[@LINE-3]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: garbage
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-SERIALIZED: [[@LINE-2]]:16: error: cannot convert value of type 'FromSerialized' to specified type 'X'
|
||||
@@ -0,0 +1,77 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1. Not finding things is okay.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
// 2. Only interface is present.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %S/Inputs/force-module-loading-mode/ %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 3. Only module is present.
|
||||
// RUN: sed -e 's/FromInterface/FromSerialized/g' %S/Inputs/force-module-loading-mode/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
|
||||
// 4. Both are present.
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 5. Both are present but the module is invalid.
|
||||
// RUN: rm %t/Lib.swiftmodule && touch %t/Lib.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=BAD-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 6. Both are present but the module can't be opened.
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/Lib.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
import Lib
|
||||
// NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib'
|
||||
// BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-SERIALIZED: [[@LINE-2]]:16: error: cannot convert value of type 'FromSerialized' to specified type 'X'
|
||||
@@ -0,0 +1,56 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/mock-sdk)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/PrebuiltModuleCache)
|
||||
|
||||
// This test makes sure that we propagate the right set of dependencies from a
|
||||
// prebuilt module to its corresponding forwarding module.
|
||||
|
||||
// Setup. Copy the mock SDK into the tmp directory.
|
||||
// RUN: cp -r %S/Inputs/mock-sdk/* %t/mock-sdk/.
|
||||
|
||||
// 1. Compile ExportedLib.swiftinterface, which a) is in the SDK, and b) depends
|
||||
// on a C module with headers that should be in the dependency list.
|
||||
// Put it in the prebuilt cache.
|
||||
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/mock-sdk/ExportedLib.swiftinterface -sdk %t/mock-sdk -o %t/PrebuiltModuleCache/ExportedLib.swiftmodule -serialize-parseable-module-interface-dependency-hashes -track-system-dependencies
|
||||
|
||||
// 2. Make sure the prebuilt module we built has SomeCModule.h as a dependency.
|
||||
|
||||
// RUN: llvm-bcanalyzer -dump %t/PrebuiltModuleCache/ExportedLib.swiftmodule | grep 'FILE_DEPENDENCY.*SomeCModule.h'
|
||||
|
||||
// 3. Typecheck this file, which imports SdkLib, which imports ExportedLib.
|
||||
// Because ExportedLib is prebuilt, we expect a forwarding module for
|
||||
// ExportedLib in the module cache, and a serialized module for SdkLib in
|
||||
// the cache.
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck %s -prebuilt-module-cache-path %t/PrebuiltModuleCache -module-cache-path %t/ModuleCache -sdk %t/mock-sdk -I %t/mock-sdk -track-system-dependencies
|
||||
|
||||
// 4. Make sure the forwarding module is installed in the cache.
|
||||
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/ModuleCache/ExportedLib-*.swiftmodule
|
||||
|
||||
// 5. Make sure the forwarding module depends on the prebuilt module and the C
|
||||
// header.
|
||||
|
||||
// RUN: grep ' *path:.*ExportedLib.swiftmodule' %t/ModuleCache/ExportedLib-*.swiftmodule
|
||||
// RUN: grep ' *path:.*SomeCModule.h' %t/ModuleCache/ExportedLib-*.swiftmodule
|
||||
|
||||
// 6. Make sure the dependencies from the forwarding module make it into the
|
||||
// cached module.
|
||||
|
||||
// RUN: llvm-bcanalyzer -dump %t/ModuleCache/SdkLib-*.swiftmodule | grep 'FILE_DEPENDENCY.*SomeCModule.h'
|
||||
|
||||
// 7. Make sure the prebuilt ExportedLib module did NOT get propagated to SdkLib.
|
||||
|
||||
// RUN: llvm-bcanalyzer -dump %t/ModuleCache/SdkLib-*.swiftmodule | not grep 'FILE_DEPENDENCY.*PrebuiltModuleCache'
|
||||
|
||||
// 8. Make sure we re-build the SdkLib module if one of the dependencies changes its mtime (but not its hash).
|
||||
// This will ensure we recorded the forwarding module's dependencies, not the prebuilt.
|
||||
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/ModuleCache/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/mock-sdk/usr/include/SomeCModule.h
|
||||
// RUN: %target-swift-frontend -typecheck %s -prebuilt-module-cache-path %t/PrebuiltModuleCache -module-cache-path %t/ModuleCache -sdk %t/mock-sdk -I %t/mock-sdk -track-system-dependencies
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/ModuleCache/SdkLib-*.swiftmodule
|
||||
|
||||
import SdkLib
|
||||
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Test will build a module TestModule that depends LeafModule (built from leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: test -f %t/LeafModule.swiftinterface
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-LEAFINTERFACE <%t/LeafModule.swiftinterface
|
||||
// CHECK-LEAFINTERFACE: {{swift-interface-format-version: [0-9\\.]+}}
|
||||
// CHECK-LEAFINTERFACE: LeafFunc
|
||||
//
|
||||
// Break LeafModule's version number
|
||||
// RUN: sed -e 's/swift-interface-format-version:.*/swift-interface-format-version: 9999.999/' %t/LeafModule.swiftinterface | tr -d '\r' > %t/LeafModule.swiftinterface.tmp
|
||||
// RUN: mv %t/LeafModule.swiftinterface.tmp %t/LeafModule.swiftinterface
|
||||
//
|
||||
// Try to build TestModule into a .swiftmodule explicitly using LeafModule via LeafModule.swiftinterface, but fail because version mismatch in LeafModule.swiftinterface.
|
||||
//
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err.txt 2>&1
|
||||
// RUN: test ! -f %t/TestModule.swiftmodule
|
||||
// This avoids a problem in Windows with test ! -f 'foo*' for a file that doesn't exist
|
||||
// RUN: %{python} -c "import sys; import glob; sys.exit(len(glob.glob('%t/modulecache/LeafModule-*.swiftmodule')) != 0)"
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-ERR <%t/err.txt
|
||||
// CHECK-ERR: {{error: unsupported version of module interface '.*[/\\]LeafModule.swiftinterface': '9999.999'}}
|
||||
// CHECK-ERR: error: no such module 'LeafModule
|
||||
|
||||
import LeafModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(LeafFunc())
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// This test specifically uses macOS deployment targets
|
||||
// REQUIRES: OS=macosx
|
||||
//
|
||||
// RUN: %empty-directory(%t)
|
||||
//
|
||||
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
// Phase 1: build LeafModule into a .swiftinterface file with -target x86_64-macosx-10.9:
|
||||
//
|
||||
// RUN: %swift -target x86_64-apple-macosx10.9 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck
|
||||
//
|
||||
// Phase 2: build OtherModule into a .swiftinterface file with -target x86_64-macosx-10.10:
|
||||
//
|
||||
// RUN: %swift -target x86_64-apple-macosx10.10 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -typecheck
|
||||
//
|
||||
// Phase 3: build TestModule in -target x86_64-apple-macosx10.11 and import both of these:
|
||||
//
|
||||
// RUN: %swift -target x86_64-apple-macosx10.11 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -typecheck
|
||||
//
|
||||
// Phase 4: make sure we only compiled LeafModule and OtherModule one time:
|
||||
//
|
||||
// RUN: NUM_LEAF_MODULES=$(find %t/modulecache -type f -name 'LeafModule-*.swiftmodule' | wc -l)
|
||||
// RUN: NUM_OTHER_MODULES=$(find %t/modulecache -type f -name 'OtherModule-*.swiftmodule' | wc -l)
|
||||
// RUN: if [ ! $NUM_LEAF_MODULES -eq 1 ]; then echo "Should only be 1 LeafModule, found $NUM_LEAF_MODULES"; exit 1; fi
|
||||
// RUN: if [ ! $NUM_OTHER_MODULES -eq 1 ]; then echo "Should only be 1 OtherModule, found $NUM_OTHER_MODULES"; exit 1; fi
|
||||
import LeafModule
|
||||
import OtherModule
|
||||
103
test/ModuleInterface/ModuleCache/module-cache-diagnostics.swift
Normal file
103
test/ModuleInterface/ModuleCache/module-cache-diagnostics.swift
Normal file
@@ -0,0 +1,103 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then revert LeafModule.swiftinterface to have a warning-provoking entry in it, and check that we get no diagnostic.
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface to have an error in it, and check that we get a diagnostic and failure.
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface to have an error in an @inlinable function body, and check we get a diagnostic and failure.
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: add an inlinable func with an unused var to LeafModule.swiftinterface (which should emit a warning); check we do get a rebuild, but no warning. (For astooscopelookup testing, must filter out that warning; see the sed command below.)
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: cp %t/LeafModule.swiftinterface %t/LeafModule.swiftinterface.backup
|
||||
// RUN: echo "@inlinable func foo() { var x = 10 }" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s 2>&1 | sed '/WARNING: TRYING Scope exclusively/d' >%t/warn.txt
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// "check warn.txt exists and is empty"
|
||||
// RUN: test -e %t/warn.txt -a ! -s %t/warn.txt
|
||||
//
|
||||
//
|
||||
// Next test: make LeafModule.swiftinterface import NotAModule (which should emit an error); check we do not get a rebuild, do get an error.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/*.swiftmodule %t/*.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: echo "import NotAModule" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err.txt 2>&1
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt
|
||||
// CHECK-ERROR: LeafModule.swiftinterface:7:8: error: no such module 'NotAModule'
|
||||
// CHECK-ERROR: OtherModule.swiftinterface:4:8: error: failed to load module 'LeafModule'
|
||||
// CHECK-ERROR: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to load module 'OtherModule'
|
||||
// CHECK-ERROR-NOT: error:
|
||||
//
|
||||
//
|
||||
// Next test: same as above, but with a .dia file
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -serialize-diagnostics -serialize-diagnostics-path %t/err.dia -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: c-index-test -read-diagnostics %t/err.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR
|
||||
//
|
||||
//
|
||||
// Next test: add an inlinable function body with an unresolved identifier to LeafModule.swiftinterface; check we do not get a rebuild and report the additional error correctly.
|
||||
//
|
||||
// RUN: mv %t/LeafModule.swiftinterface.backup %t/LeafModule.swiftinterface
|
||||
// RUN: echo "@inlinable func bar() { var x = unresolved }" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err-inline.txt 2>&1
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt
|
||||
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:6:33: error: use of unresolved identifier 'unresolved'
|
||||
// CHECK-ERROR-INLINE: OtherModule.swiftinterface:4:8: error: failed to load module 'LeafModule'
|
||||
// CHECK-ERROR-INLINE: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to load module 'OtherModule'
|
||||
// CHECK-ERROR-INLINE-NOT: error:
|
||||
//
|
||||
//
|
||||
// Next test: same as above, but with a .dia file
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -serialize-diagnostics -serialize-diagnostics-path %t/err-inline.dia -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: c-index-test -read-diagnostics %t/err-inline.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR-INLINE
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
//
|
||||
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
// Phase 1: build LeafModule into a .swiftinterface file with -swift-version 4:
|
||||
//
|
||||
// RUN: %target-swift-frontend -swift-version 4 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck
|
||||
//
|
||||
// Phase 2: build OtherModule into a .swiftinterface file with -swift-version 4.2:
|
||||
//
|
||||
// RUN: %target-swift-frontend -swift-version 4.2 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -typecheck
|
||||
//
|
||||
// Phase 3: build TestModule in -swift-version 5 and import both of these:
|
||||
//
|
||||
// RUN: %target-swift-frontend -swift-version 5 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -typecheck
|
||||
//
|
||||
// Phase 4: make sure we only compiled LeafModule and OtherModule one time:
|
||||
//
|
||||
// RUN: ls %t/modulecache | grep -c 'LeafModule-.*.swiftmodule' | %FileCheck %s
|
||||
// RUN: ls %t/modulecache | grep -c 'OtherModule-.*.swiftmodule' | %FileCheck %s
|
||||
// CHECK: 1
|
||||
|
||||
import LeafModule
|
||||
import OtherModule
|
||||
@@ -0,0 +1,23 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a parseable interface for a module SomeModule (built from some-module.swift).
|
||||
// This test checks we still build and load its corresponding .swiftmodule when the file that imports it contains an error prior to the import statement.
|
||||
|
||||
// Setup phase 1: Write the input file.
|
||||
//
|
||||
// RUN: echo 'public func SomeFunc() -> Int { return 42; }' >>%t/some-module.swift
|
||||
|
||||
// Setup phase 2: build the module.
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/SomeModule.swiftinterface -module-name SomeModule %t/some-module.swift -emit-module -o /dev/null
|
||||
|
||||
// Actual test: compile and verify the import succeeds (i.e. we only report the error in this file)
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -verify -I %t -module-cache-path %t/modulecache %s
|
||||
|
||||
unresolved // expected-error {{use of unresolved identifier 'unresolved'}}
|
||||
|
||||
import SomeModule
|
||||
|
||||
print(SomeFunc())
|
||||
72
test/ModuleInterface/ModuleCache/module-cache-init.swift
Normal file
72
test/ModuleInterface/ModuleCache/module-cache-init.swift
Normal file
@@ -0,0 +1,72 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
//
|
||||
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
// Phase 1: build LeafModule into a .swiftinterface file:
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: test -f %t/LeafModule.swiftinterface
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-LEAFINTERFACE <%t/LeafModule.swiftinterface
|
||||
// CHECK-LEAFINTERFACE: LeafFunc
|
||||
//
|
||||
//
|
||||
// Phase 2: build OtherModule into a .swiftinterface _using_ LeafModule via LeafModule.swiftinterface, creating LeafModule-*.swiftmodule along the way.
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: test -f %t/OtherModule.swiftinterface
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-OTHERINTERFACE <%t/OtherModule.swiftinterface
|
||||
// CHECK-OTHERINTERFACE: OtherFunc
|
||||
// RUN: test -f %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: llvm-bcanalyzer -dump %t/modulecache/LeafModule-*.swiftmodule | %FileCheck %s -check-prefix=CHECK-LEAFMODULE
|
||||
// CHECK-LEAFMODULE: {{MODULE_NAME.*blob data = 'LeafModule'}}
|
||||
// CHECK-LEAFMODULE: {{FILE_DEPENDENCY.*LeafModule.swiftinterface'}}
|
||||
// CHECK-LEAFMODULE: FUNC_DECL
|
||||
// RUN: llvm-bcanalyzer -dump %t/modulecache/LeafModule-*.swiftmodule | %FileCheck %s -check-prefix=CHECK-LEAFMODULE-NEGATIVE
|
||||
// CHECK-LEAFMODULE-NEGATIVE-NOT: {{FILE_DEPENDENCY.*Swift.swiftmodule([/\\].+[.]swiftmodule)?'}}
|
||||
//
|
||||
//
|
||||
// Phase 3: build TestModule into a .swiftmodule explicitly us OtherModule via OtherModule.swiftinterface, creating OtherModule-*.swiftmodule along the way.
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -emit-dependencies -emit-dependencies-path %t/TestModule.d -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: test -f %t/TestModule.swiftmodule
|
||||
// RUN: test -f %t/modulecache/OtherModule-*.swiftmodule
|
||||
// RUN: test -f %t/TestModule.d
|
||||
// RUN: llvm-bcanalyzer -dump %t/modulecache/OtherModule-*.swiftmodule | %FileCheck %s -check-prefix=CHECK-OTHERMODULE
|
||||
// CHECK-OTHERMODULE: {{MODULE_NAME.*blob data = 'OtherModule'}}
|
||||
// CHECK-OTHERMODULE-NOT: {{FILE_DEPENDENCY.*Swift.swiftmodule([/\\].+[.]swiftmodule)?'}}
|
||||
// CHECK-OTHERMODULE: {{FILE_DEPENDENCY.*LeafModule.swiftinterface'}}
|
||||
// CHECK-OTHERMODULE: {{FILE_DEPENDENCY.*OtherModule.swiftinterface'}}
|
||||
// CHECK-OTHERMODULE: FUNC_DECL
|
||||
//
|
||||
// Quirk: because the cached .swiftmodules have a hash name component that
|
||||
// integrates target, and we sort the contents of lines in a .d file by the
|
||||
// dependency's reverse-name (for reasons), the order in which the cached
|
||||
// .swiftmodules are listed in the .d file will vary _by target_.
|
||||
//
|
||||
// So we cannot write a single set of CHECK-SAME lines here that will work
|
||||
// for all targets: some will have LeafModule first, some OtherModule
|
||||
// first. So instead we just use CHECK-DAG.
|
||||
//
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-DEPENDS <%t/TestModule.d
|
||||
//
|
||||
// CHECK-DEPENDS: TestModule.swiftmodule :
|
||||
// CHECK-DEPENDS-DAG: LeafModule.swiftinterface
|
||||
// CHECK-DEPENDS-DAG: OtherModule.swiftinterface
|
||||
// CHECK-DEPENDS-DAG: Swift.swiftmodule
|
||||
// CHECK-DEPENDS-DAG: SwiftOnoneSupport.swiftmodule
|
||||
//
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-DEPENDS-NEGATIVE <%t/TestModule.d
|
||||
//
|
||||
// CHECK-DEPENDS-NEGATIVE-NOT: {{LeafModule-[^ ]+.swiftmodule}}
|
||||
// CHECK-DEPENDS-NEGATIVE-NOT: {{OtherModule-[^ ]+.swiftmodule}}
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify OtherModule.swiftinterface's content (but not size), and check only OtherModule-*.swiftmodule has a new mtime, LeafModule is unchanged.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc2() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: Change the mtime of OtherModule.swiftinterface, check we only rebuild its cached module.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: touch %t/OtherModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify OtherModule.swiftinterface's size (but not mtime), and check only OtherModule-*.swiftmodule has a new mtime, LeafModule is unchanged.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: make OtherModule.swiftinterface change size without changing mtime, check we only rebuild its cached module.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: echo "// size change" >>%t/OtherModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/OtherModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface's content (but not size), and check both cached modules have new mtimes.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
// RUN: echo 'public func LeafFunc2() -> Int { return 11; }' >>%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: Change the mtime of LeafModule.swiftinterface, check both cached modules get rebuilt.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: touch %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface's size (but not mtime), and check both cached modules have new mtimes.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: make LeafModule.swiftinterface change size without changing mtime, check both cached modules get rebuilt.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: echo "// size change" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then rebuild TestModule a second time, without changing any inputs, and confirm none of the files has a new mtime.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: rebuild output, check no intermediates gets rebuilt.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/include/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
|
||||
// Baseline check: if the prebuilt cache path does not exist, everything should
|
||||
// still work.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Baseline check: if the module is not in the prebuilt cache, build it
|
||||
// normally.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Do a manual prebuild, and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// What if the module is invalid?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name && touch %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// What if the arch is missing?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,45 @@
|
||||
// Like prebuilt-module-cache-archs.swift, but testing the fallback behavior.
|
||||
// This means we have to know the expected names in advance, so this test only
|
||||
// runs on macOS.
|
||||
|
||||
// REQUIRES: OS=macosx
|
||||
// REQUIRES: CPU=x86_64
|
||||
|
||||
// Use the short name "x86_64.swiftmodule".
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/include/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/x86_64.swiftinterface
|
||||
|
||||
// Do a manual prebuild with the long name "x86_64-apple-macos.swiftmodule",
|
||||
// and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuiltLong/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/x86_64-apple-macos.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT-LONG %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Prefer a matching name.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuiltShort/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/x86_64.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT-SHORT %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Prefer a matching name in the other direction too.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: mv %t/include/Lib.swiftmodule/x86_64.swiftinterface %t/include/Lib.swiftmodule/x86_64-apple-macos.swiftinterface
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT-LONG %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Don't do the fallback thing for long names to short names.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule/x86_64-apple-macos.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT-LONG: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuiltLong' to specified type 'X'
|
||||
// FROM-PREBUILT-SHORT: [[@LINE-3]]:16: error: cannot convert value of type 'FromPrebuiltShort' to specified type 'X'
|
||||
@@ -0,0 +1,52 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
|
||||
// First, prebuild a module and put it in the prebuilt cache.
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | tr -d '\r' > %t/Lib.swiftinterface.tmp
|
||||
// RUN: mv %t/Lib.swiftinterface.tmp %t/Lib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -module-cache-path %t/MCP -serialize-parseable-module-interface-dependency-hashes -o %t/prebuilt-cache/Lib.swiftmodule %t/Lib.swiftinterface
|
||||
|
||||
// Next, use the module and check if the forwarding module is in place.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
// RUN: cat %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Now invalidate a dependency of the prebuilt module, by changing the hash of the .swiftinterface.
|
||||
// RUN: cp %t/Lib.swiftinterface %t/Lib.swiftinterface.moved-aside
|
||||
// RUN: echo ' ' >> %t/Lib.swiftinterface
|
||||
|
||||
// Make sure the forwarding file is replaced with a real module.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Delete the cached module we just created, put the old .swiftinterface back, and create the forwarding module again
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: mv %t/Lib.swiftinterface.moved-aside %t/Lib.swiftinterface
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Move the prebuilt module out of the way, so the forwarding module points to nothing.
|
||||
// RUN: mv %t/prebuilt-cache/Lib.swiftmodule %t/prebuilt-cache/NotLib.swiftmodule
|
||||
|
||||
// Make sure we delete the existing forwarding module and rebuild from an interface.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Move the prebuilt module back to its original path
|
||||
// RUN: mv %t/prebuilt-cache/NotLib.swiftmodule %t/prebuilt-cache/Lib.swiftmodule
|
||||
|
||||
// If the forwarding module is corrupted, we shouldn't rebuild the module in the cache,
|
||||
// we should delete it and generate a new forwarding module.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/MCP/Lib-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,13 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Create a prebuilt module cache and populate it with a prebuilt module.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: %target-swift-frontend -parse-stdlib %S/Inputs/prebuilt-module-cache/Lib.swiftinterface -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
|
||||
// Compile against the module with a module cache that does not exist
|
||||
// RUN: %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/RandomPath/NonExistentCachePath -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache -prebuilt-module-cache-path %t/prebuilt-cache %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/RandomPath/NonExistentCachePath/Lib-*.swiftmodule
|
||||
|
||||
import Lib
|
||||
@@ -0,0 +1,25 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Baseline check: if the module is not in the prebuilt cache, build it
|
||||
// normally.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Do a manual prebuild, and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// What if the module is invalid?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule && touch %t/prebuilt-cache/Lib.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/ -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
import LibExporter
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,28 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// -- construct prebuilt
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// -- generate a manual prebuilt
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | tr -d '\r' | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// -- ensure we installed a forwarding module
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// -- ensure that the search path is in the root
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk / -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// This test is not supported on Windows since the root is not / but rather a
|
||||
// drive letter followed by a colon.
|
||||
// UNSUPPORTED: OS=windows-msvc
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
|
||||
// FROM-INTERFACE: [[@LINE-2]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-3]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/include/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
|
||||
// Prebuild a module for the current target CPU, and put it in the prebuilt cache under some imaginary CPU.
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %t/include/Lib.swiftmodule/%target-cpu.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/leg128.swiftmodule - -module-name Lib
|
||||
|
||||
// Make sure that, if there's a module for a different architecture
|
||||
// present in the prebuilt cache, it's ignored and the module is
|
||||
// rebuilt from an interface.
|
||||
|
||||
// RUN: not %target-swift-frontend -typecheck -module-cache-path %t/MCP -sdk %t/include -I %t/include -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck %s --check-prefix FROM-INTERFACE
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// Make sure it works fine if the module is for this architecture.
|
||||
// RUN: mv %t/prebuilt-cache/Lib.swiftmodule/leg128.swiftmodule %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: not %target-swift-frontend -typecheck -module-cache-path %t/MCP -sdk %t/include -I %t/include -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck %s --check-prefix FROM-PREBUILT
|
||||
|
||||
// Now make sure it works if there's nothing in the prebuilt cache
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// RUN: not %target-swift-frontend -typecheck -module-cache-path %t/MCP -sdk %t/include -I %t/include -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck %s --check-prefix FROM-INTERFACE
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-PREBUILT: [[@LINE-1]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
// FROM-INTERFACE: [[@LINE-2]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
38
test/ModuleInterface/ModuleCache/prebuilt-module-cache.swift
Normal file
38
test/ModuleInterface/ModuleCache/prebuilt-module-cache.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Baseline check: if the prebuilt cache path does not exist, everything should
|
||||
// still work.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Baseline check: if the module is not in the prebuilt cache, build it
|
||||
// normally.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Do a manual prebuild, and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | tr -d '\r' | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Try some variations on the detection that the search path is in the SDK:
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S//Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/prebuilt-module-cache -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/p -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/garbage-path -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk "" -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// What if the module is invalid?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule && touch %t/prebuilt-cache/Lib.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/ -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,31 @@
|
||||
// RUN: %empty-directory(%t/BuildDir/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/SecondBuildDir/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
|
||||
// RUN: echo 'public func showsUpInBothPlaces() {}' > %t/Lib.swift
|
||||
|
||||
// 1. Create a .swiftinterface file containing just one API, and put it inside a second build dir (without a .swiftmodule)
|
||||
// RUN: %target-swift-frontend -typecheck %t/Lib.swift -emit-module-interface-path %t/SecondBuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface -module-name Lib
|
||||
|
||||
// 2. Add a new API to the module, and compile just the serialized version in the build dir.
|
||||
// RUN: echo 'public func onlyInTheCompiledModule() {}' >> %t/Lib.swift
|
||||
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -o %t/BuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftmodule -emit-module-interface-path %t/BuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface -module-name Lib
|
||||
|
||||
// 3. Make sure when we compile this test file, we can access both APIs since we'll
|
||||
// load the compiled .swiftmodule instead of the .swiftinterface in the SDK.
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %t/BuildDir -F %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 4. Make sure we didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
// 5. This should also work if the swiftinterface isn't present in the first build dir.
|
||||
// RUN: rm %t/BuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %t/BuildDir -F %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 6. Make sure we /still/ didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
import Lib
|
||||
|
||||
showsUpInBothPlaces()
|
||||
onlyInTheCompiledModule()
|
||||
@@ -0,0 +1,31 @@
|
||||
// RUN: %empty-directory(%t/BuildDir)
|
||||
// RUN: %empty-directory(%t/SecondBuildDir/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
|
||||
// RUN: echo 'public func showsUpInBothPlaces() {}' > %t/Lib.swift
|
||||
|
||||
// 1. Create a .swiftinterface file containing just one API, and put it inside a second build dir (without a .swiftmodule)
|
||||
// RUN: %target-swift-frontend -typecheck %t/Lib.swift -emit-module-interface-path %t/SecondBuildDir/Lib.swiftmodule/%target-cpu.swiftinterface -module-name Lib
|
||||
|
||||
// 2. Add a new API to the module, and compile just the serialized version in the build dir.
|
||||
// RUN: echo 'public func onlyInTheCompiledModule() {}' >> %t/Lib.swift
|
||||
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -o %t/BuildDir/Lib.swiftmodule -emit-module-interface-path %t/BuildDir/Lib.swiftinterface
|
||||
|
||||
// 3. Make sure when we compile this test file, we can access both APIs since we'll
|
||||
// load the compiled .swiftmodule instead of the .swiftinterface in the SDK.
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/BuildDir -I %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 4. Make sure we didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
// 5. This should also work if the swiftinterface isn't present in the first build dir.
|
||||
// RUN: rm %t/BuildDir/Lib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/BuildDir -I %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 6. Make sure we /still/ didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
import Lib
|
||||
|
||||
showsUpInBothPlaces()
|
||||
onlyInTheCompiledModule()
|
||||
@@ -0,0 +1,25 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module -emit-module-interface-path %t/Lib.swiftinterface -emit-module-doc -parse-stdlib -o %t/Lib.swiftmodule %s
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-module.txt
|
||||
// RUN: %FileCheck %s < %t/from-module.txt
|
||||
|
||||
// RUN: rm %t/Lib.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-interface.txt
|
||||
// RUN: diff %t/from-module.txt %t/from-interface.txt
|
||||
|
||||
// Try again with architecture-specific subdirectories.
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: %target-swift-frontend -emit-module -emit-module-interface-path %t/Lib.swiftmodule/%target-cpu.swiftinterface -emit-module-doc -parse-stdlib -o %t/Lib.swiftmodule/%target-swiftmodule-name -module-name Lib %s
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-module.txt
|
||||
// RUN: %FileCheck %s < %t/from-module.txt
|
||||
|
||||
// RUN: rm %t/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-interface.txt
|
||||
// RUN: diff %t/from-module.txt %t/from-interface.txt
|
||||
|
||||
/// Very important documentation!
|
||||
public struct SomeStructWithDocumentation {}
|
||||
|
||||
// CHECK: Very important documentation!
|
||||
// CHECK-NEXT: struct SomeStructWithDocumentation {
|
||||
13
test/ModuleInterface/NoWrongSDKWarning.swiftinterface
Normal file
13
test/ModuleInterface/NoWrongSDKWarning.swiftinterface
Normal file
@@ -0,0 +1,13 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -target x86_64-apple-macos10.9
|
||||
|
||||
// Deliberately pass the wrong target at the command line and see what happens.
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %swift -sdk %sdk -target arm64-apple-ios10 -compile-module-from-interface %s -o %t/NoWrongSDKWarning.swiftmodule 2>&1 | %FileCheck -allow-empty %s
|
||||
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
public func empty()
|
||||
|
||||
// CHECK-NOT: warning:
|
||||
// CHECK-NOT: error:
|
||||
56
test/ModuleInterface/ObjC.swiftinterface
Normal file
56
test/ModuleInterface/ObjC.swiftinterface
Normal file
@@ -0,0 +1,56 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/ObjC.swiftmodule -O -enable-objc-interop %s
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/ObjC.swiftmodule -O -enable-objc-interop -enable-library-evolution %s
|
||||
|
||||
// FIXME: This test is self-contained, so it shouldn't require objc_interop
|
||||
// (just -enable-objc-interop), but it's failing in Linux SILGen.
|
||||
// https://bugs.swift.org/browse/SR-8877
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
import Foundation
|
||||
|
||||
public class SomeClass {
|
||||
@objc init?(_: Any)
|
||||
@objc func foo()
|
||||
@objc var bar: Int { get set }
|
||||
@objc subscript(_: Int) -> Int { get set }
|
||||
@objc deinit
|
||||
}
|
||||
|
||||
public class SomeClassInlinable {
|
||||
@usableFromInline init()
|
||||
@objc @inlinable convenience init?(_: Any) { self.init() }
|
||||
@objc @inlinable func foo() {}
|
||||
@objc var bar: Int {
|
||||
@inlinable get { return 0 }
|
||||
@inlinable set {}
|
||||
}
|
||||
@objc @inlinable subscript(_: Int) -> Int {
|
||||
@inlinable get { return 0 }
|
||||
@inlinable set {}
|
||||
}
|
||||
@objc deinit
|
||||
}
|
||||
|
||||
public class SomeNSObject : NSObject {
|
||||
@objc init?(_: Any)
|
||||
@objc func foo()
|
||||
@objc var bar: Int { get set }
|
||||
@objc subscript(_: Int) -> Int { get set }
|
||||
@objc deinit
|
||||
}
|
||||
|
||||
public class SomeNSObjectInlinable : NSObject {
|
||||
public override init()
|
||||
@objc @inlinable convenience init?(_: Any) { self.init() }
|
||||
@objc @inlinable func foo() {}
|
||||
@objc var bar: Int {
|
||||
@inlinable get { return 0 }
|
||||
@inlinable set {}
|
||||
}
|
||||
@objc @inlinable subscript(_: Int) -> Int {
|
||||
@inlinable get { return 0 }
|
||||
@inlinable set {}
|
||||
}
|
||||
@objc deinit
|
||||
}
|
||||
12
test/ModuleInterface/ParseStdlib.swiftinterface
Normal file
12
test/ModuleInterface/ParseStdlib.swiftinterface
Normal file
@@ -0,0 +1,12 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib
|
||||
|
||||
// Note that the "-parse-stdlib" is picked up from the module flags. It should
|
||||
// not be written in any of the invocations below.
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/ParseStdlib.swiftmodule %s
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print ParseStdlib -I %t -source-filename x -print-interface | %FileCheck %s
|
||||
|
||||
// CHECK: func test(_: Builtin.Int42)
|
||||
public func test(_: Builtin.Int42) {}
|
||||
97
test/ModuleInterface/SmokeTest.swiftinterface
Normal file
97
test/ModuleInterface/SmokeTest.swiftinterface
Normal file
@@ -0,0 +1,97 @@
|
||||
// The "flags" line in this test deliberately has no flags and no space after
|
||||
// the colon, just to make sure that works (even though it'll never be printed
|
||||
// that way).
|
||||
|
||||
// swift-module-flags:
|
||||
// swift-interface-format-version: 1.0
|
||||
|
||||
// Make sure parse-only works...
|
||||
// RUN: %target-swift-frontend -parse %s
|
||||
|
||||
// ...and then make sure parse-and-typecheck-and-serialize works.
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/SmokeTest.swiftmodule %s
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print SmokeTest -I %t -source-filename x -print-interface > %t/SmokeTest.txt
|
||||
// RUN: %FileCheck %s < %t/SmokeTest.txt
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/SmokeTest.txt
|
||||
// RUN: llvm-bcanalyzer -dump %t/SmokeTest.swiftmodule | grep FILE_DEPENDENCY
|
||||
|
||||
// CHECK-LABEL: public class TestClass
|
||||
public class TestClass {
|
||||
// CHECK: public init(){{$}}
|
||||
public init()
|
||||
|
||||
// CHECK: public func method(){{$}}
|
||||
public func method()
|
||||
|
||||
// CHECK: public subscript(_: Int) -> Void{{$}}
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
|
||||
// CHECK: public var prop: Int{{$}}
|
||||
public var prop: Int { get set }
|
||||
|
||||
// CHECK: public static var propWithNoAccessors: Int{{$}}
|
||||
public static var propWithNoAccessors: Int
|
||||
|
||||
// NEGATIVE-NOT: deinit
|
||||
deinit
|
||||
} // CHECK: {{^}$}}
|
||||
|
||||
// CHECK-LABEL: public class TestEmptyClass {
|
||||
public class TestEmptyClass {
|
||||
} // CHECK-NEXT: {{^}$}}
|
||||
|
||||
// CHECK-LABEL: public struct TestEmptyStruct {
|
||||
public struct TestEmptyStruct {
|
||||
} // CHECK-NEXT: {{^}$}}
|
||||
|
||||
// CHECK-LABEL: public enum TestEnum
|
||||
public enum TestEnum {
|
||||
// CHECK: case a
|
||||
case a
|
||||
|
||||
// CHECK: public init(){{$}}
|
||||
public init()
|
||||
|
||||
// CHECK: public func method(){{$}}
|
||||
public func method()
|
||||
|
||||
// CHECK: public subscript(_: Int) -> Void{{$}}
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
|
||||
// CHECK: public var prop: Int{{$}}
|
||||
public var prop: Int { get set }
|
||||
|
||||
// CHECK: public static var propWithNoAccessors: Int{{$}}
|
||||
public static var propWithNoAccessors: Int
|
||||
} // CHECK: {{^}$}}
|
||||
|
||||
// CHECK-LABEL: public struct TestStruct
|
||||
public struct TestStruct {
|
||||
// CHECK: public init(){{$}}
|
||||
public init()
|
||||
|
||||
// CHECK: public func method(){{$}}
|
||||
public func method()
|
||||
|
||||
// CHECK: public subscript(_: Int) -> Void{{$}}
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
|
||||
// CHECK: public var prop: Int{{$}}
|
||||
public var prop: Int { get set }
|
||||
|
||||
// CHECK: public static var propWithNoAccessors: Int{{$}}
|
||||
public static var propWithNoAccessors: Int
|
||||
} // CHECK: {{^}$}}
|
||||
|
||||
// CHECK: public let globalWithNoAccessors: Int{{$}}
|
||||
public let globalWithNoAccessors: Int
|
||||
|
||||
// CHECK: public var readOnlyVar: Int { get }{{$}}
|
||||
public var readOnlyVar: Int { get }
|
||||
|
||||
// CHECK: public var readWriteVar: Int{{$}}
|
||||
public var readWriteVar: Int { get set }
|
||||
|
||||
// CHECK: public func verySimpleFunction(){{$}}
|
||||
public func verySimpleFunction()
|
||||
289
test/ModuleInterface/access-filter.swift
Normal file
289
test/ModuleInterface/access-filter.swift
Normal file
@@ -0,0 +1,289 @@
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface %s -module-name AccessFilter
|
||||
// RUN: %FileCheck %s < %t.swiftinterface
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t.swiftinterface
|
||||
|
||||
// NEGATIVE-NOT: BAD
|
||||
|
||||
// CHECK: public func publicFn(){{$}}
|
||||
public func publicFn() {}
|
||||
internal func internalFn_BAD() {}
|
||||
private func privateFn_BAD() {}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal func ufiFn(){{$}}
|
||||
@usableFromInline internal func ufiFn() {}
|
||||
|
||||
|
||||
// CHECK: public struct PublicStruct {{[{]$}}
|
||||
public struct PublicStruct {
|
||||
// CHECK: public func publicMethod(){{$}}
|
||||
public func publicMethod() {}
|
||||
internal func internalMethod_BAD() {}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal func ufiMethod(){{$}}
|
||||
@usableFromInline internal func ufiMethod() {}
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
internal struct InternalStruct_BAD {
|
||||
public func publicMethod_BAD() {}
|
||||
internal func internalMethod_BAD() {}
|
||||
@usableFromInline internal func ufiMethod_BAD() {}
|
||||
}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal struct UFIStruct {{[{]$}}
|
||||
@usableFromInline
|
||||
internal struct UFIStruct {
|
||||
// FIXME: Arguably this should be downgraded to "@usableFromInline internal".
|
||||
// CHECK: public func publicMethod(){{$}}
|
||||
public func publicMethod() {}
|
||||
internal func internalMethod_BAD() {}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal func ufiMethod(){{$}}
|
||||
@usableFromInline internal func ufiMethod() {}
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
// CHECK: public protocol PublicProto {{[{]$}}
|
||||
public protocol PublicProto {
|
||||
// CHECK-NEXT: associatedtype Assoc = Swift.Int
|
||||
associatedtype Assoc = Int
|
||||
// CHECK-NEXT: func requirement()
|
||||
func requirement()
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
// CHECK: extension PublicProto {{[{]$}}
|
||||
extension PublicProto {
|
||||
// CHECK: public func publicMethod(){{$}}
|
||||
public func publicMethod() {}
|
||||
internal func internalMethod_BAD() {}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal func ufiMethod(){{$}}
|
||||
@usableFromInline internal func ufiMethod() {}
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
// CHECK: {{^}}extension PublicProto {{[{]$}}
|
||||
public extension PublicProto {
|
||||
// CHECK: public func publicExtPublicMethod(){{$}}
|
||||
func publicExtPublicMethod() {}
|
||||
internal func publicExtInternalMethod_BAD() {}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal func publicExtUFIMethod(){{$}}
|
||||
@usableFromInline internal func publicExtUFIMethod() {}
|
||||
}
|
||||
|
||||
internal protocol InternalProto_BAD {
|
||||
associatedtype AssocBAD = Int
|
||||
func requirementBAD()
|
||||
}
|
||||
|
||||
extension InternalProto_BAD {
|
||||
public func publicMethod_BAD() {}
|
||||
internal func internalMethod_BAD() {}
|
||||
@usableFromInline internal func ufiMethod_BAD() {}
|
||||
}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal protocol UFIProto {{[{]$}}
|
||||
@usableFromInline
|
||||
internal protocol UFIProto {
|
||||
// CHECK-NEXT: associatedtype Assoc = Swift.Int
|
||||
associatedtype Assoc = Int
|
||||
// CHECK-NEXT: func requirement()
|
||||
func requirement()
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
// CHECK: extension UFIProto {{[{]$}}
|
||||
extension UFIProto {
|
||||
// CHECK: public func publicMethod(){{$}}
|
||||
public func publicMethod() {}
|
||||
internal func internalMethod_BAD() {}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal func ufiMethod(){{$}}
|
||||
@usableFromInline internal func ufiMethod() {}
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
// CHECK: extension PublicStruct {{[{]$}}
|
||||
extension PublicStruct {
|
||||
// CHECK: @_hasInitialValue public static var secretlySettable: Swift.Int {
|
||||
// CHECK-NEXT: get
|
||||
// CHECK-NEXT: }
|
||||
public private(set) static var secretlySettable: Int = 0
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
extension InternalStruct_BAD: PublicProto {
|
||||
func requirement() {}
|
||||
internal static var dummy: Int { return 0 }
|
||||
}
|
||||
|
||||
// CHECK: extension UFIStruct : AccessFilter.PublicProto {{[{]$}}
|
||||
extension UFIStruct: PublicProto {
|
||||
// CHECK-NEXT: @usableFromInline
|
||||
// CHECK-NEXT: internal typealias Assoc = Swift.Int
|
||||
|
||||
// FIXME: Is it okay for this non-@usableFromInline implementation to satisfy
|
||||
// the protocol?
|
||||
func requirement() {}
|
||||
internal static var dummy: Int { return 0 }
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
// CHECK: public enum PublicEnum {{[{]$}}
|
||||
public enum PublicEnum {
|
||||
// CHECK-NEXT: case x
|
||||
case x
|
||||
// CHECK-NEXT: case y(Swift.Int)
|
||||
case y(Int)
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
enum InternalEnum_BAD {
|
||||
case xBAD
|
||||
}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal enum UFIEnum {{[{]$}}
|
||||
@usableFromInline enum UFIEnum {
|
||||
// CHECK-NEXT: case x
|
||||
case x
|
||||
// CHECK-NEXT: case y(Swift.Int)
|
||||
case y(Int)
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
// CHECK: public class PublicClass {{[{]$}}
|
||||
public class PublicClass {
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
class InternalClass_BAD {
|
||||
}
|
||||
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal class UFIClass {{[{]$}}
|
||||
@usableFromInline class UFIClass {
|
||||
} // CHECK: {{^[}]$}}
|
||||
|
||||
// CHECK: public struct GenericStruct<T>
|
||||
public struct GenericStruct<T> {}
|
||||
|
||||
// CHECK: extension GenericStruct where T == AccessFilter.PublicStruct {{[{]$}}
|
||||
extension GenericStruct where T == AccessFilter.PublicStruct {
|
||||
// CHECK-NEXT: public func constrainedToPublicStruct(){{$}}
|
||||
public func constrainedToPublicStruct() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
// CHECK: extension GenericStruct where T == AccessFilter.UFIStruct {{[{]$}}
|
||||
extension GenericStruct where T == AccessFilter.UFIStruct {
|
||||
// CHECK-NEXT: @usableFromInline{{$}}
|
||||
// CHECK-NEXT: internal func constrainedToUFIStruct(){{$}}
|
||||
@usableFromInline internal func constrainedToUFIStruct() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
extension GenericStruct where T == InternalStruct_BAD {
|
||||
@usableFromInline internal func constrainedToInternalStruct_BAD() {}
|
||||
}
|
||||
|
||||
// CHECK: extension GenericStruct where T == AccessFilter.PublicStruct {{[{]$}}
|
||||
extension GenericStruct where PublicStruct == T {
|
||||
// CHECK-NEXT: public func constrainedToPublicStruct2(){{$}}
|
||||
public func constrainedToPublicStruct2() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
// CHECK: extension GenericStruct where T == AccessFilter.UFIStruct {{[{]$}}
|
||||
extension GenericStruct where UFIStruct == T {
|
||||
// CHECK-NEXT: @usableFromInline{{$}}
|
||||
// CHECK-NEXT: internal func constrainedToUFIStruct2(){{$}}
|
||||
@usableFromInline internal func constrainedToUFIStruct2() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
extension GenericStruct where InternalStruct_BAD == T {
|
||||
@usableFromInline internal func constrainedToInternalStruct2_BAD() {}
|
||||
}
|
||||
|
||||
// CHECK: extension GenericStruct where T : AccessFilter.PublicProto {{[{]$}}
|
||||
extension GenericStruct where T: PublicProto {
|
||||
// CHECK-NEXT: public func constrainedToPublicProto(){{$}}
|
||||
public func constrainedToPublicProto() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
// CHECK: extension GenericStruct where T : AccessFilter.UFIProto {{[{]$}}
|
||||
extension GenericStruct where T: UFIProto {
|
||||
// CHECK-NEXT: @usableFromInline{{$}}
|
||||
// CHECK-NEXT: internal func constrainedToUFIProto(){{$}}
|
||||
@usableFromInline internal func constrainedToUFIProto() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
extension GenericStruct where T: InternalProto_BAD {
|
||||
@usableFromInline internal func constrainedToInternalProto_BAD() {}
|
||||
}
|
||||
|
||||
// CHECK: extension GenericStruct where T : AccessFilter.PublicClass {{[{]$}}
|
||||
extension GenericStruct where T: PublicClass {
|
||||
// CHECK-NEXT: public func constrainedToPublicClass(){{$}}
|
||||
public func constrainedToPublicClass() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
// CHECK: extension GenericStruct where T : AccessFilter.UFIClass {{[{]$}}
|
||||
extension GenericStruct where T: UFIClass {
|
||||
// CHECK-NEXT: @usableFromInline{{$}}
|
||||
// CHECK-NEXT: internal func constrainedToUFIClass(){{$}}
|
||||
@usableFromInline internal func constrainedToUFIClass() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
extension GenericStruct where T: InternalClass_BAD {
|
||||
@usableFromInline internal func constrainedToInternalClass_BAD() {}
|
||||
}
|
||||
|
||||
// CHECK: extension GenericStruct where T : AnyObject {{[{]$}}
|
||||
extension GenericStruct where T: AnyObject {
|
||||
// CHECK-NEXT: public func constrainedToAnyObject(){{$}}
|
||||
public func constrainedToAnyObject() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
public struct PublicAliasBase {}
|
||||
internal struct ReallyInternalAliasBase_BAD {}
|
||||
|
||||
// CHECK: public typealias PublicAlias = AccessFilter.PublicAliasBase
|
||||
public typealias PublicAlias = PublicAliasBase
|
||||
internal typealias InternalAlias_BAD = PublicAliasBase
|
||||
// CHECK: @usableFromInline
|
||||
// CHECK-NEXT: internal typealias UFIAlias = AccessFilter.PublicAliasBase
|
||||
@usableFromInline internal typealias UFIAlias = PublicAliasBase
|
||||
|
||||
internal typealias ReallyInternalAlias_BAD = ReallyInternalAliasBase_BAD
|
||||
|
||||
// CHECK: extension GenericStruct where T == AccessFilter.PublicAlias {{[{]$}}
|
||||
extension GenericStruct where T == PublicAlias {
|
||||
// CHECK-NEXT: public func constrainedToPublicAlias(){{$}}
|
||||
public func constrainedToPublicAlias() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
// CHECK: extension GenericStruct where T == AccessFilter.UFIAlias {{[{]$}}
|
||||
extension GenericStruct where T == UFIAlias {
|
||||
// CHECK-NEXT: @usableFromInline{{$}}
|
||||
// CHECK-NEXT: internal func constrainedToUFIAlias(){{$}}
|
||||
@usableFromInline internal func constrainedToUFIAlias() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
extension GenericStruct where T == InternalAlias_BAD {
|
||||
// FIXME: We could print this one by desugaring; it is indeed public.
|
||||
@usableFromInline internal func constrainedToInternalAlias() {}
|
||||
}
|
||||
extension GenericStruct where T == ReallyInternalAlias_BAD {
|
||||
@usableFromInline internal func constrainedToPrivateAlias() {}
|
||||
}
|
||||
|
||||
extension GenericStruct {
|
||||
// For the next extension's test.
|
||||
public func requirement() {}
|
||||
}
|
||||
extension GenericStruct: PublicProto where T: InternalProto_BAD {
|
||||
@usableFromInline internal func conformance_BAD() {}
|
||||
}
|
||||
|
||||
|
||||
public struct MultiGenericStruct<First, Second> {}
|
||||
|
||||
// CHECK: extension MultiGenericStruct where First == AccessFilter.PublicStruct, Second == AccessFilter.PublicStruct {{[{]$}}
|
||||
extension MultiGenericStruct where First == PublicStruct, Second == PublicStruct {
|
||||
// CHECK-NEXT: public func publicPublic(){{$}}
|
||||
public func publicPublic() {}
|
||||
} // CHECK-NEXT: {{^[}]$}}
|
||||
|
||||
extension MultiGenericStruct where First == PublicStruct, Second == InternalStruct_BAD {
|
||||
@usableFromInline internal func publicInternal_BAD() {}
|
||||
}
|
||||
extension MultiGenericStruct where First == InternalStruct_BAD, Second == PublicStruct {
|
||||
@usableFromInline internal func internalPublic_BAD() {}
|
||||
}
|
||||
16
test/ModuleInterface/attrs.swift
Normal file
16
test/ModuleInterface/attrs.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface -enable-library-evolution %s
|
||||
// RUN: %FileCheck %s < %t.swiftinterface
|
||||
|
||||
// CHECK: @_transparent public func glass() -> Swift.Int { return 0 }{{$}}
|
||||
@_transparent public func glass() -> Int { return 0 }
|
||||
|
||||
// CHECK: @_effects(readnone) public func illiterate(){{$}}
|
||||
@_effects(readnone) public func illiterate() {}
|
||||
|
||||
// CHECK-LABEL: @frozen public struct Point {
|
||||
@frozen public struct Point {
|
||||
// CHECK-NEXT: public var x: Swift.Int
|
||||
public var x: Int
|
||||
// CHECK-NEXT: public var y: Swift.Int
|
||||
public var y: Int
|
||||
} // CHECK-NEXT: {{^}$}}
|
||||
14
test/ModuleInterface/can-import.swift
Normal file
14
test/ModuleInterface/can-import.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'public func externalFunc() {}' | %target-swift-frontend -typecheck -emit-module-interface-path %t/Library.swiftinterface -
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t
|
||||
|
||||
#if canImport(Library)
|
||||
import Library
|
||||
externalFunc()
|
||||
#else
|
||||
#error("unable to import Library from its parseable interface")
|
||||
#endif
|
||||
|
||||
#if canImport(LibraryThatDoesNotExist)
|
||||
#error("should not return true for library that does not exist")
|
||||
#endif
|
||||
246
test/ModuleInterface/conformances.swift
Normal file
246
test/ModuleInterface/conformances.swift
Normal file
@@ -0,0 +1,246 @@
|
||||
// RUN: %target-swift-frontend-typecheck -emit-module-interface-path %t.swiftinterface %s
|
||||
// RUN: %FileCheck %s < %t.swiftinterface
|
||||
// RUN: %FileCheck -check-prefix CHECK-END %s < %t.swiftinterface
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t.swiftinterface
|
||||
|
||||
// NEGATIVE-NOT: BAD
|
||||
|
||||
// CHECK-LABEL: public protocol SimpleProto {
|
||||
public protocol SimpleProto {
|
||||
// CHECK: associatedtype Element
|
||||
associatedtype Element
|
||||
// CHECK: associatedtype Inferred
|
||||
associatedtype Inferred
|
||||
func inference(_: Inferred)
|
||||
} // CHECK: {{^}$}}
|
||||
|
||||
// CHECK-LABEL: public struct SimpleImpl<Element> : conformances.SimpleProto {
|
||||
public struct SimpleImpl<Element>: SimpleProto {
|
||||
// NEGATIVE-NOT: typealias Element =
|
||||
// CHECK: public func inference(_: Swift.Int){{$}}
|
||||
public func inference(_: Int) {}
|
||||
// CHECK: public typealias Inferred = Swift.Int
|
||||
} // CHECK: {{^}$}}
|
||||
|
||||
|
||||
public protocol PublicProto {}
|
||||
private protocol PrivateProto {}
|
||||
|
||||
// CHECK: public struct A1 : conformances.PublicProto {
|
||||
// NEGATIVE-NOT: extension conformances.A1
|
||||
public struct A1: PublicProto, PrivateProto {}
|
||||
// CHECK: public struct A2 : conformances.PublicProto {
|
||||
// NEGATIVE-NOT: extension conformances.A2
|
||||
public struct A2: PrivateProto, PublicProto {}
|
||||
// CHECK: public struct A3 {
|
||||
// CHECK-END: extension conformances.A3 : conformances.PublicProto {}
|
||||
public struct A3: PublicProto & PrivateProto {}
|
||||
// CHECK: public struct A4 {
|
||||
// CHECK-END: extension conformances.A4 : conformances.PublicProto {}
|
||||
public struct A4: PrivateProto & PublicProto {}
|
||||
|
||||
public protocol PublicBaseProto {}
|
||||
private protocol PrivateSubProto: PublicBaseProto {}
|
||||
|
||||
// CHECK: public struct B1 {
|
||||
// CHECK-END: extension conformances.B1 : conformances.PublicBaseProto {}
|
||||
public struct B1: PrivateSubProto {}
|
||||
// CHECK: public struct B2 : conformances.PublicBaseProto {
|
||||
// NEGATIVE-NOT: extension conformances.B2
|
||||
public struct B2: PublicBaseProto, PrivateSubProto {}
|
||||
// CHECK: public struct B3 {
|
||||
// CHECK-END: extension conformances.B3 : conformances.PublicBaseProto {}
|
||||
public struct B3: PublicBaseProto & PrivateSubProto {}
|
||||
// CHECK: public struct B4 : conformances.PublicBaseProto {
|
||||
// NEGATIVE-NOT: extension B4 {
|
||||
// NEGATIVE-NOT: extension conformances.B4
|
||||
public struct B4: PublicBaseProto {}
|
||||
extension B4: PrivateSubProto {}
|
||||
// CHECK: public struct B5 {
|
||||
// CHECK: extension B5 : conformances.PublicBaseProto {
|
||||
// NEGATIVE-NOT: extension conformances.B5
|
||||
public struct B5: PrivateSubProto {}
|
||||
extension B5: PublicBaseProto {}
|
||||
// CHECK: public struct B6 {
|
||||
// NEGATIVE-NOT: extension B6 {
|
||||
// CHECK: extension B6 : conformances.PublicBaseProto {
|
||||
// NEGATIVE-NOT: extension conformances.B6
|
||||
public struct B6 {}
|
||||
extension B6: PrivateSubProto {}
|
||||
extension B6: PublicBaseProto {}
|
||||
// CHECK: public struct B7 {
|
||||
// CHECK: extension B7 : conformances.PublicBaseProto {
|
||||
// NEGATIVE-NOT: extension B7 {
|
||||
// NEGATIVE-NOT: extension conformances.B7
|
||||
public struct B7 {}
|
||||
extension B7: PublicBaseProto {}
|
||||
extension B7: PrivateSubProto {}
|
||||
|
||||
// CHECK-LABEL: public struct OuterGeneric<T> {
|
||||
public struct OuterGeneric<T> {
|
||||
// CHECK-NEXT: public struct Inner {
|
||||
public struct Inner: PrivateSubProto {}
|
||||
// CHECK-NEXT: {{^ }$}}
|
||||
}
|
||||
// CHECK-NEXT: {{^}$}}
|
||||
|
||||
public protocol ConditionallyConformed {}
|
||||
public protocol ConditionallyConformedAgain {}
|
||||
|
||||
// CHECK-END: @available(*, unavailable)
|
||||
// CHECK-END-NEXT: extension conformances.OuterGeneric : conformances.ConditionallyConformed, conformances.ConditionallyConformedAgain where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
|
||||
extension OuterGeneric: ConditionallyConformed where T: PrivateProto {}
|
||||
extension OuterGeneric: ConditionallyConformedAgain where T == PrivateProto {}
|
||||
|
||||
// CHECK-END: extension conformances.OuterGeneric.Inner : conformances.PublicBaseProto {}
|
||||
// CHECK-END: @available(*, unavailable)
|
||||
// CHECK-END-NEXT: extension conformances.OuterGeneric.Inner : conformances.ConditionallyConformed, conformances.ConditionallyConformedAgain where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
|
||||
extension OuterGeneric.Inner: ConditionallyConformed where T: PrivateProto {}
|
||||
extension OuterGeneric.Inner: ConditionallyConformedAgain where T == PrivateProto {}
|
||||
|
||||
private protocol AnotherPrivateSubProto: PublicBaseProto {}
|
||||
|
||||
// CHECK: public struct C1 {
|
||||
// CHECK-END: extension conformances.C1 : conformances.PublicBaseProto {}
|
||||
public struct C1: PrivateSubProto, AnotherPrivateSubProto {}
|
||||
// CHECK: public struct C2 {
|
||||
// CHECK-END: extension conformances.C2 : conformances.PublicBaseProto {}
|
||||
public struct C2: PrivateSubProto & AnotherPrivateSubProto {}
|
||||
// CHECK: public struct C3 {
|
||||
// NEGATIVE-NOT: extension C3 {
|
||||
// CHECK-END: extension conformances.C3 : conformances.PublicBaseProto {}
|
||||
public struct C3: PrivateSubProto {}
|
||||
extension C3: AnotherPrivateSubProto {}
|
||||
|
||||
public protocol PublicSubProto: PublicBaseProto {}
|
||||
public protocol APublicSubProto: PublicBaseProto {}
|
||||
|
||||
// CHECK: public struct D1 : conformances.PublicSubProto {
|
||||
// NEGATIVE-NOT: extension conformances.D1
|
||||
public struct D1: PublicSubProto, PrivateSubProto {}
|
||||
// CHECK: public struct D2 : conformances.PublicSubProto {
|
||||
// NEGATIVE-NOT: extension conformances.D2
|
||||
public struct D2: PrivateSubProto, PublicSubProto {}
|
||||
// CHECK: public struct D3 {
|
||||
// CHECK-END: extension conformances.D3 : conformances.PublicBaseProto {}
|
||||
// CHECK-END: extension conformances.D3 : conformances.PublicSubProto {}
|
||||
public struct D3: PrivateSubProto & PublicSubProto {}
|
||||
// CHECK: public struct D4 {
|
||||
// CHECK-END: extension conformances.D4 : conformances.APublicSubProto {}
|
||||
// CHECK-END: extension conformances.D4 : conformances.PublicBaseProto {}
|
||||
public struct D4: APublicSubProto & PrivateSubProto {}
|
||||
// CHECK: public struct D5 {
|
||||
// CHECK: extension D5 : conformances.PublicSubProto {
|
||||
// NEGATIVE-NOT: extension conformances.D5
|
||||
public struct D5: PrivateSubProto {}
|
||||
extension D5: PublicSubProto {}
|
||||
// CHECK: public struct D6 : conformances.PublicSubProto {
|
||||
// NEGATIVE-NOT: extension D6 {
|
||||
// NEGATIVE-NOT: extension conformances.D6
|
||||
public struct D6: PublicSubProto {}
|
||||
extension D6: PrivateSubProto {}
|
||||
|
||||
private typealias PrivateProtoAlias = PublicProto
|
||||
|
||||
// CHECK: public struct E1 {
|
||||
// CHECK-END: extension conformances.E1 : conformances.PublicProto {}
|
||||
public struct E1: PrivateProtoAlias {}
|
||||
|
||||
private typealias PrivateSubProtoAlias = PrivateSubProto
|
||||
|
||||
// CHECK: public struct F1 {
|
||||
// CHECK-END: extension conformances.F1 : conformances.PublicBaseProto {}
|
||||
public struct F1: PrivateSubProtoAlias {}
|
||||
|
||||
private protocol ClassConstrainedProto: PublicProto, AnyObject {}
|
||||
|
||||
public class G1: ClassConstrainedProto {}
|
||||
// CHECK: public class G1 {
|
||||
// CHECK-END: extension conformances.G1 : conformances.PublicProto {}
|
||||
|
||||
public class Base {}
|
||||
private protocol BaseConstrainedProto: Base, PublicProto {}
|
||||
|
||||
public class H1: Base, ClassConstrainedProto {}
|
||||
// CHECK: public class H1 : conformances.Base {
|
||||
// CHECK-END: extension conformances.H1 : conformances.PublicProto {}
|
||||
|
||||
public struct MultiGeneric<T, U, V> {}
|
||||
extension MultiGeneric: PublicProto where U: PrivateProto {}
|
||||
|
||||
// CHECK: public struct MultiGeneric<T, U, V> {
|
||||
// CHECK-END: @available(*, unavailable)
|
||||
// CHECK-END-NEXT: extension conformances.MultiGeneric : conformances.PublicProto where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
|
||||
|
||||
|
||||
internal struct InternalImpl_BAD: PrivateSubProto {}
|
||||
internal struct InternalImplConstrained_BAD<T> {}
|
||||
extension InternalImplConstrained_BAD: PublicProto where T: PublicProto {}
|
||||
internal struct InternalImplConstrained2_BAD<T> {}
|
||||
extension InternalImplConstrained2_BAD: PublicProto where T: PrivateProto {}
|
||||
|
||||
public struct WrapperForInternal {
|
||||
internal struct InternalImpl_BAD: PrivateSubProto {}
|
||||
internal struct InternalImplConstrained_BAD<T> {}
|
||||
internal struct InternalImplConstrained2_BAD<T> {}
|
||||
}
|
||||
extension WrapperForInternal.InternalImplConstrained_BAD: PublicProto where T: PublicProto {}
|
||||
extension WrapperForInternal.InternalImplConstrained2_BAD: PublicProto where T: PrivateProto {}
|
||||
|
||||
|
||||
internal protocol ExtraHashable: Hashable {}
|
||||
extension Bool: ExtraHashable {}
|
||||
|
||||
@available(iOS, unavailable)
|
||||
@available(macOS, unavailable)
|
||||
public struct CoolTVType: PrivateSubProto {}
|
||||
// CHECK: public struct CoolTVType {
|
||||
// CHECK-END: @available(iOS, unavailable)
|
||||
// CHECK-END-NEXT: @available(OSX, unavailable)
|
||||
// CHECK-END-NEXT: extension conformances.CoolTVType : conformances.PublicBaseProto {}
|
||||
|
||||
@available(macOS 10.99, *)
|
||||
public struct VeryNewMacType: PrivateSubProto {}
|
||||
// CHECK: public struct VeryNewMacType {
|
||||
// CHECK-END: @available(OSX 10.99, *)
|
||||
// CHECK-END-NEXT: extension conformances.VeryNewMacType : conformances.PublicBaseProto {}
|
||||
|
||||
public struct VeryNewMacProto {}
|
||||
@available(macOS 10.98, *)
|
||||
extension VeryNewMacProto: PrivateSubProto {}
|
||||
// CHECK: public struct VeryNewMacProto {
|
||||
// CHECK-END: @available(OSX 10.98, *)
|
||||
// CHECK-END-NEXT: extension conformances.VeryNewMacProto : conformances.PublicBaseProto {}
|
||||
|
||||
public struct PrivateProtoConformer {}
|
||||
extension PrivateProtoConformer : PrivateProto {
|
||||
public var member: Int { return 0 }
|
||||
}
|
||||
// CHECK: public struct PrivateProtoConformer {
|
||||
// CHECK: extension PrivateProtoConformer {
|
||||
// CHECK-NEXT: public var member: Swift.Int {
|
||||
// CHECK-NEXT: get
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: {{^}$}}
|
||||
// NEGATIVE-NOT: extension conformances.PrivateProtoConformer
|
||||
|
||||
// NEGATIVE-NOT: extension {{(Swift.)?}}Bool{{.+}}Hashable
|
||||
// NEGATIVE-NOT: extension {{(Swift.)?}}Bool{{.+}}Equatable
|
||||
|
||||
|
||||
@available(macOS 10.97, iOS 22, *)
|
||||
@available(tvOS, unavailable)
|
||||
@available(swift 4.2.123)
|
||||
public struct NestedAvailabilityOuter {
|
||||
@available(iOS 23, *)
|
||||
public struct Inner: PrivateSubProto {}
|
||||
}
|
||||
|
||||
// CHECK-END: @available(swift 4.2.123)
|
||||
// CHECK-END-NEXT: @available(OSX 10.97, iOS 23, *)
|
||||
// CHECK-END-NEXT: @available(tvOS, unavailable)
|
||||
// CHECK-END-NEXT: extension conformances.NestedAvailabilityOuter.Inner : conformances.PublicBaseProto {}
|
||||
|
||||
|
||||
// CHECK-END: @usableFromInline
|
||||
// CHECK-END-NEXT: internal protocol _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
|
||||
50
test/ModuleInterface/convenience-init.swift
Normal file
50
test/ModuleInterface/convenience-init.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Generate the parseable interface of the current file via the merge-modules step
|
||||
// RUN: %target-build-swift -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
|
||||
|
||||
// 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
|
||||
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)
|
||||
}
|
||||
// MERGE: {{^}} public convenience init()
|
||||
// SINGLE: {{^}} convenience public init()
|
||||
convenience public init() {
|
||||
self.init(z: 1)
|
||||
}
|
||||
}
|
||||
|
||||
public class Derived2: Base {
|
||||
// CHECK: {{^}} public init()
|
||||
public init() {
|
||||
super.init(x: 1)
|
||||
}
|
||||
|
||||
// MERGE: {{^}} override public convenience init(x: Swift.Int)
|
||||
// SINGLE: {{^}} override convenience public init(x: Swift.Int)
|
||||
override convenience public init(x: Int) {
|
||||
self.init()
|
||||
}
|
||||
}
|
||||
12
test/ModuleInterface/dataflow-errors.swift
Normal file
12
test/ModuleInterface/dataflow-errors.swift
Normal file
@@ -0,0 +1,12 @@
|
||||
// RUN: rm -f %t
|
||||
// RUN: not %target-swift-frontend -emit-module-interface-path %t -emit-module -o /dev/null %s
|
||||
// RUN: test ! -f %t
|
||||
// RUN: %target-swift-frontend -emit-module-interface-path %t -typecheck %s
|
||||
// RUN: test -f %t
|
||||
|
||||
public struct BadInit {
|
||||
public var x: Int
|
||||
public init() {
|
||||
return // without initializing 'x'
|
||||
}
|
||||
}
|
||||
56
test/ModuleInterface/default-args.swift
Normal file
56
test/ModuleInterface/default-args.swift
Normal file
@@ -0,0 +1,56 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/Test~partial.swiftmodule -module-name Test -primary-file %s
|
||||
// RUN: %target-swift-frontend -merge-modules -emit-module -o %t/Test.swiftmodule %t/Test~partial.swiftmodule
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=Test -source-filename=x -I %t -prefer-type-repr=false -fully-qualified-types=true | %FileCheck %s
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t/Test.swiftinterface -module-name Test -enable-library-evolution %s
|
||||
// RUN: rm %t/Test.swiftmodule
|
||||
// RUN: echo "import Test" > %t/test-client.swift
|
||||
// RUN: %target-swift-frontend -typecheck -I%t %t/test-client.swift
|
||||
// RUN: %FileCheck %s < %t/Test.swiftinterface
|
||||
|
||||
// CHECK: class Base {
|
||||
public class Base {
|
||||
// CHECK: init(x: Swift.Int = 3)
|
||||
public init(x: Int = 3) {}
|
||||
public convenience init(convInit: Int) {
|
||||
self.init(x: convInit)
|
||||
}
|
||||
// CHECK: foo(y: Swift.Int = 42)
|
||||
public func foo(y: Int = 42) {}
|
||||
}
|
||||
|
||||
// CHECK: class Derived : Test.Base {
|
||||
public class Derived: Base {
|
||||
// CHECK: init(y: Swift.Int)
|
||||
public convenience init(y: Int) {
|
||||
self.init()
|
||||
}
|
||||
|
||||
// CHECK-NOT: init(convInit: Swift.Int = super)
|
||||
// CHECK: override {{(public )?}}init(x: Swift.Int = super)
|
||||
// CHECK-NOT: init(convInit: Swift.Int = super)
|
||||
}
|
||||
|
||||
public enum Enum {
|
||||
// CHECK: case pie(filling: Swift.String = "apple")
|
||||
case pie(filling: String = "apple")
|
||||
}
|
||||
|
||||
public struct HasSubscript {
|
||||
// CHECK: subscript(x: Swift.Int = 0) -> Swift.Int {
|
||||
public subscript(x: Int = 0) -> Int { return 0 }
|
||||
}
|
||||
|
||||
// CHECK: func hasClosureDefaultArg(_ x: () -> Swift.Void = {
|
||||
// CHECK-NEXT: })
|
||||
public func hasClosureDefaultArg(_ x: () -> Void = {
|
||||
}) {
|
||||
}
|
||||
|
||||
// CHECK: func hasMagicDefaultArgs(_ f: Swift.String = #file, _ fu: Swift.String = #function, _ l: Swift.Int = #line)
|
||||
public func hasMagicDefaultArgs(_ f: String = #file, _ fu: String = #function, _ l: Int = #line) {}
|
||||
|
||||
// CHECK: func hasSimpleDefaultArgs(_ x: Swift.Int = 0, b: Swift.Int = 1)
|
||||
public func hasSimpleDefaultArgs(_ x: Int = 0, b: Int = 1) {
|
||||
}
|
||||
25
test/ModuleInterface/default-prebuilt-module-location.swift
Normal file
25
test/ModuleInterface/default-prebuilt-module-location.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
// 1. Create folders for a) our Swift module, b) the module cache, and c) a
|
||||
// fake resource dir with a default prebuilt module cache inside.
|
||||
// RUN: %empty-directory(%t/PrebuiltModule.swiftmodule)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/ResourceDir/%target-sdk-name/prebuilt-modules/PrebuiltModule.swiftmodule)
|
||||
|
||||
// 2. Define some public API
|
||||
// RUN: echo 'public struct InPrebuiltModule {}' > %t/PrebuiltModule.swift
|
||||
|
||||
// 3. Compile this into a module and put it into the default prebuilt cache
|
||||
// location relative to the fake resource dir. Also drop an interface into
|
||||
// the build dir.
|
||||
// RUN: %target-swift-frontend -emit-module %t/PrebuiltModule.swift -o %t/ResourceDir/%target-sdk-name/prebuilt-modules/PrebuiltModule.swiftmodule/%target-cpu.swiftmodule -module-name PrebuiltModule -parse-stdlib -emit-module-interface-path %t/PrebuiltModule.swiftmodule/%target-cpu.swiftinterface
|
||||
|
||||
// 4. Import this prebuilt module, but DON'T pass in -prebuilt-module-cache-path, it should use the implicit one.
|
||||
// RUN: %target-swift-frontend -typecheck -resource-dir %t/ResourceDir -I %t %s -parse-stdlib -module-cache-path %t/ModuleCache -sdk %t
|
||||
|
||||
// 5. Make sure we installed a forwarding module in the module cache.
|
||||
// RUN: %{python} %S/ModuleCache/Inputs/check-is-forwarding-module.py %t/ModuleCache/PrebuiltModule-*.swiftmodule
|
||||
|
||||
import PrebuiltModule
|
||||
|
||||
func x<T>(_ x: T) {}
|
||||
|
||||
x(InPrebuiltModule.self)
|
||||
79
test/ModuleInterface/enums-layout.swift
Normal file
79
test/ModuleInterface/enums-layout.swift
Normal file
@@ -0,0 +1,79 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-build-swift -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 -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 -force-single-frontend-invocation -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 -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, i32* @"$s3Lib15FutureproofEnumO1byA2CmFWC"
|
||||
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib15FutureproofEnumOMa"
|
||||
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
|
||||
// CHECK: call void {{%.+}}(%swift.opaque* noalias %0, i32 [[CASE]], %swift.type* [[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{{.+}}testFutureproofIndirectEnum
|
||||
func testFutureproofIndirectEnum() -> FutureproofIndirectEnum {
|
||||
// CHECK: [[CASE:%.+]] = load i32, i32* @"$s3Lib23FutureproofIndirectEnumO1cyA2CmFWC"
|
||||
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib23FutureproofIndirectEnumOMa"
|
||||
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
|
||||
// CHECK: call void {{%.+}}(%swift.opaque* noalias %0, i32 [[CASE]], %swift.type* [[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, i32* @"$s3Lib27FutureproofIndirectCaseEnumO1cyA2CmFWC"
|
||||
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib27FutureproofIndirectCaseEnumOMa"
|
||||
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
|
||||
// CHECK: call void {{%.+}}(%swift.opaque* noalias %0, i32 [[CASE]], %swift.type* [[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
|
||||
}
|
||||
73
test/ModuleInterface/escape-Type-and-Protocol.swift
Normal file
73
test/ModuleInterface/escape-Type-and-Protocol.swift
Normal file
@@ -0,0 +1,73 @@
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path - %s | %FileCheck %s
|
||||
|
||||
// CHECK: public let Type: Swift.Int
|
||||
public let Type = 0
|
||||
|
||||
// CHECK: public struct A {
|
||||
public struct A {
|
||||
// CHECK-NEXT: public struct `Type` {
|
||||
// CHECK-NEXT: }
|
||||
public struct `Type` {}
|
||||
// CHECK-NEXT: }
|
||||
}
|
||||
|
||||
// CHECK: public class B {
|
||||
public class B {
|
||||
// CHECK-NEXT: public class `Type` {
|
||||
// CHECK: }
|
||||
public class `Type` {}
|
||||
|
||||
// CHECK-NEXT: @_hasInitialValue public var `Type`: Swift.Int
|
||||
public var `Type` = 0
|
||||
// CHECK: }
|
||||
}
|
||||
|
||||
// CHECK: public struct C {
|
||||
public struct C {
|
||||
// CHECK: public enum `Type` {
|
||||
public enum `Type` {
|
||||
// CHECK: }
|
||||
}
|
||||
// CHECK-NEXT: }
|
||||
}
|
||||
|
||||
// CHECK: public struct D {
|
||||
public struct D {
|
||||
// CHECK: public typealias `Type` = Swift.Int
|
||||
public typealias `Type` = Int
|
||||
// CHECK-NEXT: }
|
||||
}
|
||||
|
||||
// CHECK: public protocol BestProtocol {
|
||||
public protocol BestProtocol {
|
||||
// CHECK-NEXT: associatedtype `Type`
|
||||
associatedtype `Type`
|
||||
// CHECK-NEXT: }
|
||||
}
|
||||
|
||||
// CHECK: public enum CoolEnum {
|
||||
public enum CoolEnum {
|
||||
// CHECK-NEXT: case `Type`
|
||||
case `Type`
|
||||
// CHECK-NEXT: case `Protocol`
|
||||
case `Protocol`
|
||||
// CHECK-NEXT: case `init`
|
||||
case `init`
|
||||
// CHECK-NEXT: case `self`
|
||||
case `self`
|
||||
|
||||
// We allow Type and Protocol as method names, but we should still print them
|
||||
// escaped in case we tighten this restriction.
|
||||
// CHECK-NEXT: public func `Type`()
|
||||
public func Type() {}
|
||||
// CHECK-NEXT: public func `Protocol`()
|
||||
public func Protocol() {}
|
||||
// CHECK: }
|
||||
}
|
||||
|
||||
// CHECK: public enum UncoolEnum {
|
||||
public enum UncoolEnum {
|
||||
// CHECK-NEXT: case `Type`, `Protocol`
|
||||
case `Type`, `Protocol`
|
||||
// CHECK: }
|
||||
}
|
||||
19
test/ModuleInterface/exported-module-name.swift
Normal file
19
test/ModuleInterface/exported-module-name.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t/CoreKitClient.swiftinterface -module-name CoreKitClient -I %S/Inputs/exported-module-name-before %s
|
||||
// RUN: %FileCheck -implicit-check-not BAD %s < %t/CoreKitClient.swiftinterface
|
||||
|
||||
// Test that we can rebuild it even when the "export as" module goes away.
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/CoreKitClient.swiftmodule -I %S/Inputs/exported-module-name-after %t/CoreKitClient.swiftinterface
|
||||
|
||||
// CHECK: import CoreKit
|
||||
import CoreKit
|
||||
|
||||
// CHECK-LABEL: public struct CKThingWrapper : Swift.RawRepresentable {
|
||||
public struct CKThingWrapper: RawRepresentable {
|
||||
public var rawValue: CKThing
|
||||
public init(rawValue: CKThing) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
// Note that this is CoreKit.CKThing, not ExportAsCoreKit.CKThing
|
||||
// CHECK: public typealias RawValue = CoreKit.CKThing
|
||||
} // CHECK: {{^}$}}
|
||||
@@ -0,0 +1,70 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface %s
|
||||
// RUN: %FileCheck %s --check-prefix FROMSOURCE --check-prefix NONRESILIENT --check-prefix COMMON < %t.swiftinterface
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t-resilient.swiftinterface -enable-library-evolution %s
|
||||
// RUN: %FileCheck %s --check-prefix FROMSOURCE --check-prefix RESILIENT --check-prefix COMMON < %t-resilient.swiftinterface
|
||||
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/Test.swiftmodule %t.swiftinterface -disable-objc-attr-requires-foundation-module
|
||||
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/Test.swiftmodule -module-name Test -emit-module-interface-path - | %FileCheck %s --check-prefix FROMMODULE --check-prefix NONRESILIENT --check-prefix COMMON
|
||||
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/TestResilient.swiftmodule -enable-library-evolution %t-resilient.swiftinterface -disable-objc-attr-requires-foundation-module
|
||||
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/TestResilient.swiftmodule -module-name TestResilient -enable-library-evolution -emit-module-interface-path - | %FileCheck %s --check-prefix FROMMODULE --check-prefix RESILIENT --check-prefix COMMON
|
||||
|
||||
// COMMON: @frozen public struct MyStruct {
|
||||
@frozen
|
||||
public struct MyStruct {
|
||||
// COMMON: public var publicVar: Swift.Bool = false
|
||||
public var publicVar: Bool = false
|
||||
|
||||
// COMMON: internal var internalVar: (Swift.Bool, Swift.Bool) = (false, true)
|
||||
internal var internalVar: (Bool, Bool) = (false, true)
|
||||
|
||||
// COMMON: private var privateVar: Swift.Bool = Bool(4 < 10)
|
||||
private var privateVar: Bool = Bool(4 < 10)
|
||||
|
||||
// COMMON: @usableFromInline
|
||||
// COMMON-NEXT: internal var ufiVar: Swift.Bool = true
|
||||
@usableFromInline internal var ufiVar: Bool = true
|
||||
|
||||
// COMMON: public var multiVar1: Swift.Bool = Bool(false), (multiVar2, multiVar3): (Swift.Bool, Swift.Bool) = (true, 3 == 0)
|
||||
public var multiVar1: Bool = Bool(false), (multiVar2, multiVar3): (Bool, Bool) = (true, 3 == 0)
|
||||
|
||||
// NONRESILIENT: @_hasInitialValue public static var staticVar: Swift.Bool
|
||||
// RESILIENT: {{^}} public static var staticVar: Swift.Bool
|
||||
public static var staticVar: Bool = Bool(true && false)
|
||||
|
||||
// FROMSOURCE: @inlinable internal init() {}
|
||||
// FROMMODULE: @inlinable internal init(){{$}}
|
||||
@inlinable init() {}
|
||||
}
|
||||
|
||||
// COMMON: @_fixed_layout public class MyClass {
|
||||
@_fixed_layout
|
||||
public class MyClass {
|
||||
// COMMON: public var publicVar: Swift.Bool = false
|
||||
public var publicVar: Bool = false
|
||||
|
||||
// COMMON: internal var internalVar: Swift.Bool = false
|
||||
internal var internalVar: Bool = false
|
||||
|
||||
// COMMON: private var privateVar: Swift.UInt8 = UInt8(2)
|
||||
private var privateVar: UInt8 = UInt8(2)
|
||||
|
||||
// COMMON: @usableFromInline
|
||||
// COMMON-NEXT: internal var ufiVar: Swift.Bool = true
|
||||
@usableFromInline internal var ufiVar: Bool = true
|
||||
|
||||
// NONRESILIENT: @_hasInitialValue public static var staticVar: Swift.Bool
|
||||
// RESILIENT: {{^}} public static var staticVar: Swift.Bool
|
||||
public static var staticVar: Bool = Bool(true && false)
|
||||
|
||||
// FROMSOURCE: @inlinable internal init() {}
|
||||
// FROMMODULE: @inlinable internal init(){{$}}
|
||||
@inlinable init() {}
|
||||
}
|
||||
|
||||
// NONRESILIENT: @_hasInitialValue public var topLevelVar: Swift.Bool
|
||||
// RESILIENT: {{^}}public var topLevelVar: Swift.Bool
|
||||
public var topLevelVar: Bool = Bool(false && !true)
|
||||
35
test/ModuleInterface/function_builders.swift
Normal file
35
test/ModuleInterface/function_builders.swift
Normal file
@@ -0,0 +1,35 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -typecheck -module-name FunctionBuilders -emit-module-interface-path %t/FunctionBuilders.swiftinterface %s
|
||||
// RUN: %FileCheck %s < %t/FunctionBuilders.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -typecheck -verify %S/Inputs/function_builders_client.swift
|
||||
|
||||
@_functionBuilder
|
||||
public struct TupleBuilder {
|
||||
public static func buildBlock<T1, T2>(_ t1: T1, _ t2: T2) -> (T1, T2) {
|
||||
return (t1, t2)
|
||||
}
|
||||
|
||||
public static func buildBlock<T1, T2, T3>(_ t1: T1, _ t2: T2, _ t3: T3)
|
||||
-> (T1, T2, T3) {
|
||||
return (t1, t2, t3)
|
||||
}
|
||||
|
||||
public static func buildBlock<T1, T2, T3, T4>(_ t1: T1, _ t2: T2, _ t3: T3, _ t4: T4)
|
||||
-> (T1, T2, T3, T4) {
|
||||
return (t1, t2, t3, t4)
|
||||
}
|
||||
|
||||
public static func buildBlock<T1, T2, T3, T4, T5>(
|
||||
_ t1: T1, _ t2: T2, _ t3: T3, _ t4: T4, _ t5: T5
|
||||
) -> (T1, T2, T3, T4, T5) {
|
||||
return (t1, t2, t3, t4, t5)
|
||||
}
|
||||
|
||||
public static func buildDo<T>(_ value: T) -> T { return value }
|
||||
public static func buildIf<T>(_ value: T?) -> T? { return value }
|
||||
}
|
||||
|
||||
// CHECK-LABEL: public func tuplify<T>(_ cond: Swift.Bool, @FunctionBuilders.TupleBuilder body: (Swift.Bool) -> T)
|
||||
public func tuplify<T>(_ cond: Bool, @TupleBuilder body: (Bool) -> T) {
|
||||
print(body(cond))
|
||||
}
|
||||
18
test/ModuleInterface/iboutlet-private-set.swift
Normal file
18
test/ModuleInterface/iboutlet-private-set.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -typecheck -enable-library-evolution -disable-objc-attr-requires-foundation-module -module-name Foo -emit-module-interface-path %t/Foo.swiftinterface %s
|
||||
// RUN: %FileCheck %s -input-file %t/Foo.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Foo.swiftinterface -o %t/Foo.swiftmodule -module-name Foo
|
||||
|
||||
// Test the interface we generate for @IBOutlet private(set) properties is
|
||||
// consumable.
|
||||
|
||||
@objc public class MyType {}
|
||||
|
||||
open class Bar {
|
||||
// CHECK: @objc @IBOutlet weak public var foo: Foo.MyType! {
|
||||
// CHECK-NEXT: get
|
||||
// CHECK-NEXT: }
|
||||
@IBOutlet public private(set) weak var foo: MyType!
|
||||
}
|
||||
111
test/ModuleInterface/if-configs.swift
Normal file
111
test/ModuleInterface/if-configs.swift
Normal file
@@ -0,0 +1,111 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/Test~partial.swiftmodule -module-name Test -primary-file %s
|
||||
// RUN: %target-swift-frontend -merge-modules -emit-module -o %t/Test.swiftmodule %t/Test~partial.swiftmodule
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=Test -source-filename=x -I %t -prefer-type-repr=false -fully-qualified-types=true | %FileCheck %s
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface -enable-library-evolution %s
|
||||
// RUN: %FileCheck %s < %t.swiftinterface
|
||||
|
||||
// CHECK: func hasClosureDefaultArgWithComplexNestedPoundIfs(_ x: () -> Swift.Void = {
|
||||
// CHECK-NOT: #if NOT_PROVIDED
|
||||
// CHECK-NOT: print("should not exist")
|
||||
// CHECK-NOT: #elseif !NOT_PROVIDED
|
||||
// CHECK: let innerClosure = {
|
||||
// CHECK-NOT: #if false
|
||||
// CHECK-NOT: print("should also not exist")
|
||||
// CHECK-NOT: #else
|
||||
// CHECK: print("should exist")
|
||||
// CHECK-NOT: #endif
|
||||
// CHECK: }
|
||||
// CHECK-NOT: #endif
|
||||
// CHECK: })
|
||||
public func hasClosureDefaultArgWithComplexNestedPoundIfs(_ x: () -> Void = {
|
||||
#if NOT_PROVIDED
|
||||
print("should not exist")
|
||||
#elseif !NOT_PROVIDED
|
||||
let innerClosure = {
|
||||
#if false
|
||||
print("should also not exist")
|
||||
#else
|
||||
print("should exist")
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}) {
|
||||
}
|
||||
|
||||
// CHECK: func hasClosureDefaultArgWithComplexPoundIf(_ x: () -> Swift.Void = {
|
||||
// CHECK-NOT: #if NOT_PROVIDED
|
||||
// CHECK-NOT: print("should not exist")
|
||||
// CHECK-NOT: #else
|
||||
// CHECK-NOT: #if NOT_PROVIDED
|
||||
// CHECK-NOT: print("should also not exist")
|
||||
// CHECK-NOT: #else
|
||||
// CHECK: print("should exist"){{$}}
|
||||
// CHECK-NOT: #if !second
|
||||
// CHECK: print("should also exist"){{$}}
|
||||
// CHECK-NOT: #endif
|
||||
// CHECK-NEXT: })
|
||||
public func hasClosureDefaultArgWithComplexPoundIf(_ x: () -> Void = {
|
||||
#if NOT_PROVIDED
|
||||
print("should not exist")
|
||||
#else
|
||||
#if NOT_PROVIDED
|
||||
print("should also not exist")
|
||||
#else
|
||||
print("should exist")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !second
|
||||
print("should also exist")
|
||||
#endif
|
||||
}) {
|
||||
}
|
||||
|
||||
// CHECK: func hasClosureDefaultArgWithMultilinePoundIfCondition(_ x: () -> Swift.Void = {
|
||||
// CHECK-NOT: #if (
|
||||
// CHECK-NOT: !false && true
|
||||
// CHECK-NOT: )
|
||||
// CHECK: print("should appear")
|
||||
// CHECK-NOT: #endif
|
||||
// CHECK-NOT: #if (
|
||||
// CHECK-NOT: !true
|
||||
// CHECK-NOT: )
|
||||
// CHECK-NOT: print("should not appear")
|
||||
// CHECK-NOT: #else
|
||||
// CHECK: print("also should appear")
|
||||
// CHECK-NOT: #endif
|
||||
// CHECK-NEXT: })
|
||||
public func hasClosureDefaultArgWithMultilinePoundIfCondition(_ x: () -> Void = {
|
||||
#if (
|
||||
!false && true
|
||||
)
|
||||
print("should appear")
|
||||
#endif
|
||||
|
||||
#if (
|
||||
!true
|
||||
)
|
||||
print("should not appear")
|
||||
#else
|
||||
print("also should appear")
|
||||
#endif
|
||||
}) {
|
||||
}
|
||||
|
||||
// CHECK: func hasClosureDefaultArgWithSinglePoundIf(_ x: () -> Swift.Void = {
|
||||
// CHECK-NOT: #if true
|
||||
// CHECK: print("true")
|
||||
// CHECK-NOT: #else
|
||||
// CHECK-NOT: print("false")
|
||||
// CHECK-NOT: #endif
|
||||
// CHECK-NEXT: })
|
||||
public func hasClosureDefaultArgWithSinglePoundIf(_ x: () -> Void = {
|
||||
#if true
|
||||
print("true")
|
||||
#else
|
||||
print("false")
|
||||
#endif
|
||||
}) {
|
||||
}
|
||||
23
test/ModuleInterface/imports-submodule-order.swift
Normal file
23
test/ModuleInterface/imports-submodule-order.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path - %s -I %S/Inputs/imports-submodule-order/ | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path - %s -I %S/Inputs/imports-submodule-order/ -D XY | %FileCheck %s
|
||||
|
||||
#if XY
|
||||
@_exported import X.Submodule
|
||||
@_exported import Y.Submodule
|
||||
|
||||
#else
|
||||
@_exported import Y.Submodule
|
||||
@_exported import X.Submodule
|
||||
|
||||
#endif
|
||||
|
||||
// The order below is not alphabetical, just deterministic given a set of
|
||||
// imports across any number of files and in any order.
|
||||
|
||||
// CHECK-NOT: import
|
||||
// CHECK: import X.Submodule{{$}}
|
||||
// CHECK-NEXT: import Y.Submodule{{$}}
|
||||
// CHECK-NEXT: {{^}}import Swift{{$}}
|
||||
// CHECK-NEXT: import X{{$}}
|
||||
// CHECK-NEXT: import Y{{$}}
|
||||
// CHECK-NOT: import
|
||||
29
test/ModuleInterface/imports.swift
Normal file
29
test/ModuleInterface/imports.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/empty.swiftmodule %S/../Inputs/empty.swift
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/emptyButWithLibraryEvolution.swiftmodule %S/../Inputs/empty.swift -enable-library-evolution
|
||||
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path - %s %S/Inputs/imports-other.swift -I %S/Inputs/imports-clang-modules/ -I %t -verify -swift-version 5 -enable-library-evolution | %FileCheck -implicit-check-not BAD %s
|
||||
|
||||
|
||||
@_exported import empty // expected-warning {{module 'empty' was not compiled with library evolution support; using it means binary compatibility for 'imports' can't be guaranteed}}
|
||||
@_exported import emptyButWithLibraryEvolution
|
||||
import B.B2
|
||||
import func C.c // expected-warning {{scoped imports are not yet supported in module interfaces}}
|
||||
import D
|
||||
@_implementationOnly import Secret_BAD
|
||||
|
||||
@_implementationOnly import NotSoSecret // expected-note {{imported as implementation-only here}}
|
||||
import NotSoSecret2 // expected-warning {{'NotSoSecret2' inconsistently imported as implementation-only}}
|
||||
|
||||
// CHECK-NOT: import
|
||||
// CHECK: {{^}}import A{{$}}
|
||||
// CHECK-NEXT: {{^}}import B{{$}}
|
||||
// CHECK-NEXT: {{^}}import B.B2{{$}}
|
||||
// CHECK-NEXT: {{^}}import B.B3{{$}}
|
||||
// CHECK-NEXT: {{^}}import C/*.c*/{{$}}
|
||||
// CHECK-NEXT: {{^}}import D{{$}}
|
||||
// CHECK-NEXT: {{^}}import NotSoSecret{{$}}
|
||||
// CHECK-NEXT: {{^}}import NotSoSecret2{{$}}
|
||||
// CHECK-NEXT: {{^}}import Swift{{$}}
|
||||
// CHECK-NEXT: {{^}}@_exported import empty{{$}}
|
||||
// CHECK-NEXT: {{^}}@_exported import emptyButWithLibraryEvolution{{$}}
|
||||
// CHECK-NOT: import
|
||||
@@ -0,0 +1,65 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name InheritedDefaults
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
import Swift
|
||||
|
||||
public class Bar {
|
||||
// note associated with the expected error in (F) below
|
||||
public init(x: Int = 24, y: Int, z: Int = 42) // expected-note {{corresponding parameter declared here}}
|
||||
|
||||
public init(a: Int, b: Int = 99)
|
||||
public convenience init(convInit: Int = 45) {}
|
||||
|
||||
// note associated with the expected error in (D) below
|
||||
public convenience init(first: Int, second: Int = 88, third: Int, fourth: Int) // expected-note {{overridden declaration is here}}
|
||||
}
|
||||
|
||||
public class Foo: Bar {
|
||||
|
||||
// A) designated overriding designated - valid
|
||||
public override init(x: Int = super, y: Int, z: Int = super)
|
||||
|
||||
// B) convenience shadowing convenience
|
||||
public convenience init(convInit: Int = super) // expected-error {{default value inheritance via 'super' is only valid on the parameters of designated initializers}}
|
||||
|
||||
// C) convenience overriding designated
|
||||
public override convenience init(a: Int, b: Int = super) // expected-error {{default value inheritance via 'super' is only valid on the parameters of designated initializers}}
|
||||
|
||||
// D) designated shadowing convenience
|
||||
public init(first: Int, second: Int = super, third: Int, fourth: Int) // expected-error {{default value inheritance via 'super' can only be used when overriding a designated initializer}}
|
||||
|
||||
// E) not in initializer
|
||||
public subscript(k: Int = super) -> Int { get } // expected-error {{default value inheritance via 'super' is only valid on the parameters of designated initializers}}
|
||||
public func foo(z: Int = super) // expected-error {{default value inheritance via 'super' is only valid on the parameters of designated initializers}}
|
||||
}
|
||||
|
||||
public class Baz: Bar {
|
||||
|
||||
// F) Matching param not defaulted
|
||||
public override init(x: Int = super, y: Int = super, z: Int = super) // expected-error {{default value inheritance via 'super' requires that the corresponding parameter of the overridden designated initializer has a default value}}
|
||||
}
|
||||
|
||||
public class Direct: Bar {
|
||||
public override init(x: Int = super, y: Int, z: Int = super)
|
||||
|
||||
// G) Doesn't override anything
|
||||
public override init(other: Int = super, value: Int) // expected-error {{argument labels for initializer 'init(other:value:)' do not match those of overridden initializer 'init(a:b:)'}}
|
||||
// expected-error@-1 {{default value inheritance via 'super' can only be used when overriding a designated initializer}}
|
||||
}
|
||||
|
||||
public class Indirect: Direct {
|
||||
|
||||
// H) Chain of inherited defaults - valid all the way down
|
||||
public override init(x: Int = super, y: Int, z: Int = super)
|
||||
|
||||
// I) Chain of inherited defaults - invalid further down (and diagnosed there)
|
||||
public override init(other: Int = super, value: Int)
|
||||
}
|
||||
|
||||
public enum Bob {
|
||||
case bar(p: Int)
|
||||
public init(foo: String = super /*comment*/) // expected-error {{default value inheritance via 'super' can only be used when overriding a designated initializer}}
|
||||
}
|
||||
50
test/ModuleInterface/inherited-defaults-execution.swift
Normal file
50
test/ModuleInterface/inherited-defaults-execution.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
// REQUIRES: executable_test
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// UNSUPPORTED: swift_test_mode_optimize_none_with_implicit_dynamic
|
||||
// UNSUPPORTED: swift_test_mode_optimize_with_implicit_dynamic
|
||||
|
||||
// 1) Build the 'Inherited' library and its interface from this file
|
||||
//
|
||||
// RUN: %target-build-swift-dylib(%t/%target-library-name(Inherited)) -emit-module-path %t/Inherited.swiftmodule -emit-module-interface-path %t/Inherited.swiftinterface -module-name Inherited %s
|
||||
// RUN: rm %t/Inherited.swiftmodule
|
||||
|
||||
// 2) Check the interface includes the synthesized initializers of the base
|
||||
// class in the derived class explicitly and uses the '= super' syntax to
|
||||
// inherit its default arguments.
|
||||
//
|
||||
// RUN: cat %t/Inherited.swiftinterface | %FileCheck --check-prefix=INTERFACE %s
|
||||
//
|
||||
// INTERFACE: public class Base {
|
||||
// INTERFACE: public init(x: Swift.Int = 45, y: Swift.Int = 98)
|
||||
// INTERFACE: }
|
||||
// INTERFACE: public class Derived : Inherited.Base {
|
||||
// INTERFACE: override public init(x: Swift.Int = super, y: Swift.Int = super)
|
||||
// INTERFACE: }
|
||||
|
||||
// 4) Generate a main.swift file that uses the 'Inherited' library and makes use
|
||||
// of the inherited default arguments
|
||||
//
|
||||
// RUN: echo "import Inherited" > %t/main.swift
|
||||
// RUN: echo "print(Derived().x)" >> %t/main.swift
|
||||
// RUN: echo "print(Derived().y)" >> %t/main.swift
|
||||
|
||||
// 5) Build and run the executable, checking the defaulted arguments resulted in
|
||||
// the correct values being stored
|
||||
//
|
||||
// RUN: %target-build-swift -I%t -L%t -lInherited -o %t/main %target-rpath(%t) %t/main.swift -swift-version 5
|
||||
// RUN: %target-codesign %t/main %t/%target-library-name(Inherited)
|
||||
// RUN: %target-run %t/main %t/%target-library-name(Inherited) | %FileCheck --check-prefix=OUTPUT %s
|
||||
//
|
||||
// OUTPUT: 45
|
||||
// OUTPUT-NEXT: 98
|
||||
|
||||
public class Base {
|
||||
public let x: Int
|
||||
public let y: Int
|
||||
public init(x: Int = 45, y: Int = 98) {
|
||||
self.x = x
|
||||
self.y = y
|
||||
}
|
||||
}
|
||||
public class Derived: Base {}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user