Merge pull request #38897 from apple/revert-38649-problem/37170485

Revert "[Tests] Add a test to round-trip types through mangled names."
This commit is contained in:
Mishal Shah
2021-08-16 14:08:01 -07:00
committed by GitHub
19 changed files with 4 additions and 736 deletions

View File

@@ -384,16 +384,6 @@ code for the target that is not the build machine:
Add ``REQUIRES: static_stdlib`` to the test. Add ``REQUIRES: static_stdlib`` to the test.
* ``%target-rtti-opt``: the ``-frtti`` or ``-fno-rtti`` option required to
link with the Swift libraries on the target platform.
* ``%target-cxx-lib``: the argument to add to the command line when using
``swiftc`` and linking in a C++ object file. Typically ``-lc++`` or
``-lstdc++`` depending on platform.
* ``%target-msvc-runtime-opt``: for Windows, the MSVC runtime option, e.g.
``-MD``, to use when building C/C++ code to link with Swift.
Always use ``%target-*`` substitutions unless you have a good reason. For Always use ``%target-*`` substitutions unless you have a good reason. For
example, an exception would be a test that checks how the compiler handles example, an exception would be a test that checks how the compiler handles
mixing module files for incompatible platforms (that test would need to compile mixing module files for incompatible platforms (that test would need to compile

View File

@@ -268,9 +268,8 @@ public:
const ContextDescriptor * const ContextDescriptor *
_searchConformancesByMangledTypeName(Demangle::NodePointer node); _searchConformancesByMangledTypeName(Demangle::NodePointer node);
SWIFT_RUNTIME_EXPORT
Demangle::NodePointer _swift_buildDemanglingForMetadata(const Metadata *type, Demangle::NodePointer _swift_buildDemanglingForMetadata(const Metadata *type,
Demangle::Demangler &Dem); Demangle::Demangler &Dem);
/// Callback used to provide the substitution of a generic parameter /// Callback used to provide the substitution of a generic parameter
/// (described by depth/index) to its metadata. /// (described by depth/index) to its metadata.
@@ -368,15 +367,13 @@ public:
unsigned index) const; unsigned index) const;
}; };
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
/// Retrieve the type metadata described by the given demangled type name. /// Retrieve the type metadata described by the given demangled type name.
/// ///
/// \p substGenericParam Function that provides generic argument metadata /// \p substGenericParam Function that provides generic argument metadata
/// given a particular generic parameter specified by depth/index. /// given a particular generic parameter specified by depth/index.
/// \p substWitnessTable Function that provides witness tables given a /// \p substWitnessTable Function that provides witness tables given a
/// particular dependent conformance index. /// particular dependent conformance index.
SWIFT_RUNTIME_EXPORT SWIFT_CC(swift) SWIFT_CC(swift)
TypeLookupErrorOr<TypeInfo> swift_getTypeByMangledNode( TypeLookupErrorOr<TypeInfo> swift_getTypeByMangledNode(
MetadataRequest request, MetadataRequest request,
Demangler &demangler, Demangler &demangler,
@@ -391,14 +388,13 @@ public:
/// given a particular generic parameter specified by depth/index. /// given a particular generic parameter specified by depth/index.
/// \p substWitnessTable Function that provides witness tables given a /// \p substWitnessTable Function that provides witness tables given a
/// particular dependent conformance index. /// particular dependent conformance index.
SWIFT_RUNTIME_EXPORT SWIFT_CC(swift) SWIFT_CC(swift)
TypeLookupErrorOr<TypeInfo> swift_getTypeByMangledName( TypeLookupErrorOr<TypeInfo> swift_getTypeByMangledName(
MetadataRequest request, MetadataRequest request,
StringRef typeName, StringRef typeName,
const void * const *arguments, const void * const *arguments,
SubstGenericParameterFn substGenericParam, SubstGenericParameterFn substGenericParam,
SubstDependentWitnessTableFn substWitnessTable); SubstDependentWitnessTableFn substWitnessTable);
#pragma clang diagnostic pop
/// Function object that produces substitutions for the generic parameters /// Function object that produces substitutions for the generic parameters
/// that occur within a mangled name, using the complete set of generic /// that occur within a mangled name, using the complete set of generic

View File

@@ -1,74 +0,0 @@
#include "swift/ABI/Metadata.h"
#include "swift/Demangling/Demangle.h"
#include "swift/Reflection/TypeRefBuilder.h"
#include "swift/Remote/MetadataReader.h"
#include "swift/Remote/InProcessMemoryReader.h"
#include "Private.h"
#include <cstdio>
using namespace swift;
static std::string nameForMetadata(const Metadata *md)
{
Demangle::StackAllocatedDemangler<1024> dem;
auto nodeTree = _swift_buildDemanglingForMetadata(md, dem);
if (!nodeTree)
return "<unknown>";
std::string result = Demangle::nodeToString(nodeTree);
return result;
}
extern "C" SWIFT_CC(swift) void roundTripType(const Metadata *md) {
// Get a name for it
const std::string mdName = ::nameForMetadata(md);
// Convert it to a Node tree
Demangle::StackAllocatedDemangler<1024> dem;
auto nodeTree = _swift_buildDemanglingForMetadata(md, dem);
// Mangle that
std::string mangledName = Demangle::mangleNode(nodeTree);
// Look up the result
auto result = swift_getTypeByMangledName(MetadataState::Abstract,
mangledName,
nullptr,
[](unsigned, unsigned){ return nullptr; },
[](const Metadata *, unsigned) { return nullptr; });
if (result.isError()) {
auto err = result.getError();
char *errStr = err->copyErrorString();
printf("FAIL: %s (%p) -> %s -> ERROR %s\n",
mdName.c_str(), md, mangledName.c_str(), errStr);
err->freeErrorString(errStr);
nodeTree->dump();
result = swift_getTypeByMangledNode(MetadataState::Abstract,
dem,
nodeTree,
nullptr,
[](unsigned, unsigned){ return nullptr; },
[](const Metadata *, unsigned) { return nullptr; });
if (result.isError()) {
err = result.getError();
char *errStr = err->copyErrorString();
printf("=> Also failed on node: %s\n", errStr);
err->freeErrorString(errStr);
}
return;
}
const Metadata *md2 = result.getType().getMetadata();
std::string md2Name = "<FAIL>";
if (md2)
md2Name = ::nameForMetadata(md2);
printf("%s: %s (%p) -> %s -> %s (%p)\n",
md == md2 ? "PASS" : "FAIL",
mdName.c_str(), md, mangledName.c_str(), md2Name.c_str(), md2);
}

View File

@@ -1,2 +0,0 @@
@_silgen_name("roundTripType")
public func roundTripType(_: Any.Type)

View File

@@ -1,19 +0,0 @@
import RoundTrip
public func test() {
roundTripType(Int.self)
roundTripType(UInt.self)
roundTripType(Float.self)
roundTripType(Double.self)
roundTripType(Int8.self)
roundTripType(Int16.self)
roundTripType(Int32.self)
roundTripType(Int64.self)
roundTripType(UInt8.self)
roundTripType(UInt16.self)
roundTripType(UInt32.self)
roundTripType(UInt64.self)
}

View File

@@ -1,6 +0,0 @@
import RoundTrip
public func test() {
roundTripType(Array<(Int) async -> ()>.self)
roundTripType(Array<(Int) async throws -> ()>.self)
}

View File

@@ -1,35 +0,0 @@
import RoundTrip
protocol P {}
protocol Q {}
class C {}
class D : C, P, Q {}
public func test() {
roundTripType(Any.self)
roundTripType(AnyObject.self)
roundTripType(P.self)
roundTripType((C & P).self)
roundTripType((P & AnyObject).self)
roundTripType((P & Q).self)
roundTripType((C & P & Q).self)
roundTripType((P & Q & AnyObject).self)
roundTripType(Any.Type.self)
roundTripType(AnyObject.Type.self)
roundTripType(P.Type.self)
roundTripType((C & P).Type.self)
roundTripType((P & AnyObject).Type.self)
roundTripType((P & Q).Type.self)
roundTripType((C & P & Q).Type.self)
roundTripType((P & Q & AnyObject).Type.self)
roundTripType(Any.Protocol.self)
roundTripType(AnyObject.Protocol.self)
roundTripType(P.Protocol.self)
roundTripType((C & P).Protocol.self)
roundTripType((P & AnyObject).Protocol.self)
roundTripType((P & Q).Protocol.self)
roundTripType((C & P & Q).Protocol.self)
roundTripType((P & Q & AnyObject).Protocol.self)
}

View File

@@ -1,34 +0,0 @@
import RoundTrip
struct Concrete {}
extension Concrete {
struct Nested {}
}
struct Generic<T> {}
protocol Proto {}
struct Foo : Proto {}
class Bar {}
extension Generic where T : Proto {
struct Nested1 {}
}
extension Generic where T == Int {
struct Nested2 {}
}
extension Generic where T: AnyObject {
struct NestedViaAnyObject {}
}
public func test() {
roundTripType(Concrete.Nested.self)
roundTripType(Generic<Foo>.Nested1.self)
roundTripType(Generic<Int>.Nested2.self)
roundTripType(Generic<Bar>.NestedViaAnyObject.self)
}

View File

@@ -1,14 +0,0 @@
import RoundTrip
class Class {}
let fn: (Int, Class, __owned Class, Any, inout Int) -> (Int, Class, Any) = {
_, _, _, _, _ in fatalError()
}
let fn2: () throws -> () = {}
public func test() {
roundTripType(type(of: fn))
roundTripType(type(of: fn2))
}

View File

@@ -1,84 +0,0 @@
import RoundTrip
protocol First {
associatedtype Assoc : First
// Just to confuse things -- a method with the same name as an
// associated type
func Assoc(_: Int) -> Int
}
protocol Second {
associatedtype Assoc : Second
}
struct OuterFirst<A : First, B : First> {
struct Inner<C : First, D : First> {
func method(a: A, b: B, c: C, d: D) {
do {
let _: (A, A.Assoc, A.Assoc.Assoc) -> () = { _, _, _ in }
}
do {
let _: (B, B.Assoc, B.Assoc.Assoc) -> () = { _, _, _ in }
}
do {
let _: (C, C.Assoc, C.Assoc.Assoc) -> () = { _, _, _ in }
}
do {
let _: (D, D.Assoc, D.Assoc.Assoc) -> () = { _, _, _ in }
}
}
}
}
struct OuterBoth<A : First & Second, B : First & Second> {
struct Inner<C : First & Second, D : First & Second> {
func method(a: A, b: B, c: C, d: D) {
do {
let _: (A, A.Assoc, A.Assoc.Assoc) -> () = { _, _, _ in }
}
do {
let _: (B, B.Assoc, B.Assoc.Assoc) -> () = { _, _, _ in }
}
do {
let _: (C, C.Assoc, C.Assoc.Assoc) -> () = { _, _, _ in }
}
do {
let _: (D, D.Assoc, D.Assoc.Assoc) -> () = { _, _, _ in }
}
}
}
}
struct F1: First {
typealias Assoc = F2
func Assoc(_ x: Int) -> Int { return x + 1 }
}
struct F2: First {
typealias Assoc = F1
func Assoc(_ x: Int) -> Int { return x * 2 }
}
struct FS1: First, Second {
typealias Assoc = FS2
func Assoc(_ x: Int) -> Int { return x - 1 }
}
struct FS2: First, Second {
typealias Assoc = FS1
func Assoc(_ x: Int) -> Int { return x / 2 }
}
public func test() {
roundTripType(OuterFirst<F1,F2>.self)
roundTripType(OuterBoth<FS1,FS2>.self)
roundTripType(OuterFirst<F1,F2>.Inner<F2,F1>.self)
roundTripType(OuterBoth<FS1,FS2>.Inner<FS2,FS1>.self)
roundTripType(type(of:OuterFirst<F1,F2>.Inner<F2,F1>.method))
roundTripType(type(of:OuterBoth<FS1,FS2>.Inner<FS2,FS1>.method))
}

View File

@@ -1,121 +0,0 @@
import RoundTrip
struct Outer {
enum Inner {
case a
init() { fatalError() }
}
enum GenericInner<T, U> {
case a
init() { fatalError() }
}
}
enum GenericOuter<T, U> {
case a
init() { fatalError() }
struct Inner {}
struct GenericInner<T, U> {}
struct InnerWhere where T == GenericOuter<U, U> {}
}
protocol P {}
struct ImplementsP: P {}
struct Constrained<T : P> {}
func generic<T>(_: Constrained<T>) {}
protocol STSTagProtocol {}
struct STSOuter : STSTagProtocol {}
enum STSContainer<T : STSTagProtocol> {
class Superclass {}
class Subclass<U>: Superclass where T == STSOuter {
class ExtraNested: Superclass {}
class ExtraNestedWhere: Superclass where U: Subclass<T> {}
}
class GenericSuperclass<U> {}
class Subclass2<U>: GenericSuperclass<U> where T == STSOuter {}
class Subclass3<U: Collection>: Superclass where T == U.Element {}
class MoreNesting<X> {
class Subclass<U>: Superclass where T == STSOuter {}
}
struct Fields<U> where T == STSOuter {
var x: T?
var y: U?
}
enum Cases<U> where T == STSOuter {
case a(T)
case b(U)
}
}
// A new type with an easily-recognizable, easily-strippable suffix character.
enum STSContainer<T : STSTagProtocol> {
class Superclass {}
class GenericSuperclass<U> {}
}
extension STSContainer where T == STSOuter {
class Subclass<U>: Superclass {
class ExtraNested: Superclass {}
}
class Subclass2<U>: GenericSuperclass<U> {}
class MoreNesting<X> {
class Subclass<U>: Superclass {}
}
struct Fields<U> {
var x: T?
var y: U?
}
enum Cases<U> {
case a(T)
case b(U)
}
}
public func test() {
roundTripType(Outer.self)
roundTripType(Outer.Inner.self)
roundTripType(Outer.GenericInner<Int, String>.self)
roundTripType(Outer.GenericInner<UInt, Double>.self)
roundTripType(GenericOuter<Int, Float>.Inner.self)
roundTripType(GenericOuter<UInt, String>.GenericInner<Float, Double>.self)
roundTripType(GenericOuter<GenericOuter<Bool, Bool>, Bool>.InnerWhere.self)
roundTripType(GenericOuter<Int, String>.self)
roundTripType(Constrained<ImplementsP>.self)
roundTripType(STSContainer<STSOuter>.Subclass<Int>.self)
roundTripType(STSContainer<STSOuter>.Subclass<Int>.self)
roundTripType(STSContainer<STSOuter>.Subclass2<Int>.self)
roundTripType(STSContainer<STSOuter>.Subclass2<Int>.self)
roundTripType(STSContainer<STSOuter>.Subclass3<Array<STSOuter>>.self)
roundTripType(STSContainer<STSOuter>.Subclass<Int>.ExtraNested.self)
roundTripType(STSContainer<STSOuter>.Subclass<STSContainer<STSOuter>.Subclass<STSOuter>>.ExtraNestedWhere.self)
roundTripType(STSContainer<STSOuter>.Subclass<Int>.ExtraNested.self)
roundTripType(STSContainer<STSOuter>.MoreNesting<Bool>.Subclass<Int>.self)
roundTripType(STSContainer<STSOuter>.MoreNesting<Bool>.Subclass<Int>.self)
roundTripType(STSContainer<STSOuter>.Fields<Int>.self)
roundTripType(STSContainer<STSOuter>.Fields<Int>.self)
roundTripType(STSContainer<STSOuter>.Cases<Int>.self)
roundTripType(STSContainer<STSOuter>.Cases<Int>.self)
}

View File

@@ -1,31 +0,0 @@
// We need Objective-C support for this test
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
import Foundation
import RoundTrip
@objc protocol OurObjCProtocol {}
class OurObjCClass: NSObject, OurObjCProtocol {}
public func test() {
roundTripType(NSSet.self)
roundTripType(NSFastEnumeration.self)
roundTripType(OurObjCProtocol.self)
roundTripType(NSCache<NSNumber, NSString>.self)
roundTripType(PropertyListSerialization.WriteOptions.self)
roundTripType(NSSet.Type.self)
roundTripType(NSFastEnumeration.Type.self)
roundTripType(OurObjCProtocol.Type.self)
roundTripType(NSCache<NSNumber, NSString>.Type.self)
roundTripType(PropertyListSerialization.WriteOptions.Type.self)
roundTripType(NSFastEnumeration.Protocol.self)
roundTripType(OurObjCProtocol.Protocol.self)
}
#else
public func test() {
print("No Objective-C support, so skipping this test")
}
#endif

View File

@@ -1,32 +0,0 @@
import RoundTrip
protocol P {}
extension Int: P {}
@available(macOS 10.15, *)
func foo() -> some P { return 0 }
@available(macOS 10.15, *)
var prop: some P { return 0 }
@available(macOS 10.15, *)
func bar() -> some Sequence { return [] }
struct G<T> {}
extension G where T == Int {
@available(macOS 10.15, *)
var baz: some P { return 0 }
}
public func test() {
if #available(macOS 10.15, *) {
roundTripType(type(of:foo))
roundTripType(type(of:prop))
roundTripType(type(of:bar))
roundTripType(type(of:G<Int>().baz))
roundTripType(type(of:bar()).Element.self)
} else {
print("Skipped as there is no support for `some Foo` syntax")
}
}

View File

@@ -1,15 +0,0 @@
import RoundTrip
class Class {}
let c = Class()
weak var weakVar: Class? = c
unowned let unownedVar: Class = c
unowned(unsafe) let unmanagedVar: Class = c
public func test() {
roundTripType(type(of: weakVar))
roundTripType(type(of: unownedVar))
roundTripType(type(of: unmanagedVar))
}

View File

@@ -1,99 +0,0 @@
import RoundTrip
public func test() {
roundTripType(SIMD2<Int>.self)
roundTripType(SIMD3<Int>.self)
roundTripType(SIMD4<Int>.self)
roundTripType(SIMD8<Int>.self)
roundTripType(SIMD16<Int>.self)
roundTripType(SIMD32<Int>.self)
roundTripType(SIMD64<Int>.self)
roundTripType(SIMD2<UInt>.self)
roundTripType(SIMD3<UInt>.self)
roundTripType(SIMD4<UInt>.self)
roundTripType(SIMD8<UInt>.self)
roundTripType(SIMD16<UInt>.self)
roundTripType(SIMD32<UInt>.self)
roundTripType(SIMD64<UInt>.self)
roundTripType(SIMD2<Float>.self)
roundTripType(SIMD3<Float>.self)
roundTripType(SIMD4<Float>.self)
roundTripType(SIMD8<Float>.self)
roundTripType(SIMD16<Float>.self)
roundTripType(SIMD32<Float>.self)
roundTripType(SIMD64<Float>.self)
roundTripType(SIMD2<Double>.self)
roundTripType(SIMD3<Double>.self)
roundTripType(SIMD4<Double>.self)
roundTripType(SIMD8<Double>.self)
roundTripType(SIMD16<Double>.self)
roundTripType(SIMD32<Double>.self)
roundTripType(SIMD64<Double>.self)
roundTripType(SIMD2<Int8>.self)
roundTripType(SIMD3<Int8>.self)
roundTripType(SIMD4<Int8>.self)
roundTripType(SIMD8<Int8>.self)
roundTripType(SIMD16<Int8>.self)
roundTripType(SIMD32<Int8>.self)
roundTripType(SIMD64<Int8>.self)
roundTripType(SIMD2<Int16>.self)
roundTripType(SIMD3<Int16>.self)
roundTripType(SIMD4<Int16>.self)
roundTripType(SIMD8<Int16>.self)
roundTripType(SIMD16<Int16>.self)
roundTripType(SIMD32<Int16>.self)
roundTripType(SIMD64<Int16>.self)
roundTripType(SIMD2<Int32>.self)
roundTripType(SIMD3<Int32>.self)
roundTripType(SIMD4<Int32>.self)
roundTripType(SIMD8<Int32>.self)
roundTripType(SIMD16<Int32>.self)
roundTripType(SIMD32<Int32>.self)
roundTripType(SIMD64<Int32>.self)
roundTripType(SIMD2<Int64>.self)
roundTripType(SIMD3<Int64>.self)
roundTripType(SIMD4<Int64>.self)
roundTripType(SIMD8<Int64>.self)
roundTripType(SIMD16<Int64>.self)
roundTripType(SIMD32<Int64>.self)
roundTripType(SIMD64<Int64>.self)
roundTripType(SIMD2<UInt8>.self)
roundTripType(SIMD3<UInt8>.self)
roundTripType(SIMD4<UInt8>.self)
roundTripType(SIMD8<UInt8>.self)
roundTripType(SIMD16<UInt8>.self)
roundTripType(SIMD32<UInt8>.self)
roundTripType(SIMD64<UInt8>.self)
roundTripType(SIMD2<UInt16>.self)
roundTripType(SIMD3<UInt16>.self)
roundTripType(SIMD4<UInt16>.self)
roundTripType(SIMD8<UInt16>.self)
roundTripType(SIMD16<UInt16>.self)
roundTripType(SIMD32<UInt16>.self)
roundTripType(SIMD64<UInt16>.self)
roundTripType(SIMD2<UInt32>.self)
roundTripType(SIMD3<UInt32>.self)
roundTripType(SIMD4<UInt32>.self)
roundTripType(SIMD8<UInt32>.self)
roundTripType(SIMD16<UInt32>.self)
roundTripType(SIMD32<UInt32>.self)
roundTripType(SIMD64<UInt32>.self)
roundTripType(SIMD2<UInt64>.self)
roundTripType(SIMD3<UInt64>.self)
roundTripType(SIMD4<UInt64>.self)
roundTripType(SIMD8<UInt64>.self)
roundTripType(SIMD16<UInt64>.self)
roundTripType(SIMD32<UInt64>.self)
roundTripType(SIMD64<UInt64>.self)
}

View File

@@ -1,55 +0,0 @@
import RoundTrip
func ownedString(_ s: __owned String) -> () {
}
func variadic(_ ints: Int...) -> () {
}
public func test() {
roundTripType((() -> ()).self)
roundTripType(((inout String) -> ()).self)
roundTripType(((Int, Float) -> ()).self)
roundTripType(((inout Int, Float) -> ()).self)
roundTripType(((inout Int, inout Float) -> ()).self)
roundTripType(((Int, inout Float) -> ()).self)
roundTripType(((Int, inout String, Float) -> ()).self)
roundTripType(((inout Int, String, inout Float, Double) -> ()).self)
roundTripType(((String, Int, Double, Float) -> ()).self)
roundTripType(((Int, Float) -> ()).self)
roundTripType(((Int, Float, Int) -> ()).self)
roundTripType((Int.Type, x: Float, Int).self)
roundTripType((x: Int, Float, y: Int.Type).self)
roundTripType(((@escaping () -> ()) -> ()).self)
roundTripType(Array<@convention(c) () -> ()>.self)
roundTripType(Array<(@escaping @convention(block) () -> (), @convention(block) () -> ()) -> ()>.self)
roundTripType(Int.Type.self)
roundTripType(((inout String) -> ()).Type.self)
roundTripType(((Int, Float) -> ()).Type.self)
roundTripType(((inout Int, Float) -> ()).Type.self)
roundTripType(((inout Int, inout Float) -> ()).Type.self)
roundTripType(((Int, inout Float) -> ()).Type.self)
roundTripType(((Int, inout String, Float) -> ()).Type.self)
roundTripType(((inout Int, String, inout Float, Double) -> ()).Type.self)
roundTripType(((String, Int, Double, Float) -> ()).Type.self)
roundTripType(((Int, Float) -> ()).Type.self)
roundTripType(((Int, Float, Int) -> ()).Type.self)
roundTripType((Int.Type, x: Float, Int).Type.self)
roundTripType((x: Int, Float, y: Int.Type).Type.self)
roundTripType(((@escaping () -> ()) -> ()).Type.self)
roundTripType(Array<@convention(c) () -> ()>.Type.self)
roundTripType(Array<(@escaping @convention(block) () -> (), @convention(block) () -> ()) -> ()>.Type.self)
// rdar://81587763: [SR-15025]: Function type syntax doesn't accept variadics
// or __owned
//
//roundTripType(((__owned String) -> ()).self)
//roundTripType(((__owned String) -> ()).Type.self)
roundTripType(type(of: ownedString))
roundTripType(type(of:type(of: ownedString)))
//roundTripType(((Int...) -> ()).self)
//roundTripType(((Int...) -> ()).Type.self)
roundTripType(type(of: variadic))
roundTripType(type(of:type(of: variadic)))
}

View File

@@ -1,44 +0,0 @@
import RoundTrip
typealias Alias = Int
struct Outer {
typealias Alias = Int
struct Inner {
typealias Alias = Int
}
}
struct GenericOuter<T> {
typealias Alias = Int
struct Inner {
typealias Alias = Int
}
}
protocol Proto {
typealias Alias = Int
}
extension Proto {
typealias OtherAlias = Int
}
extension GenericOuter where T : Proto {
typealias ConditionalAlias = Int
}
struct Conforms : Proto {}
public func test() {
roundTripType(Alias.self)
roundTripType(Outer.Alias.self)
roundTripType(Outer.Inner.Alias.self)
roundTripType(GenericOuter<Int>.Alias.self)
roundTripType(GenericOuter<Int>.Inner.Alias.self)
roundTripType(Proto.Alias.self)
roundTripType(Proto.OtherAlias.self)
roundTripType(GenericOuter<Conforms>.ConditionalAlias.self)
}

View File

@@ -1,23 +0,0 @@
// RUN: %empty-directory(%t)
// RUN: %target-clang -std=c++14 %target-rtti-opt %target-pic-opt %target-msvc-runtime-opt -g -c %S/Inputs/RoundTrip/RoundTrip.cpp -I%swift_obj_root/include -I%swift_src_root/include -I%swift_src_root/stdlib/include -I%swift_src_root/stdlib/public/runtime -I%llvm_src_root/include -I%llvm_obj_root/include -o %t/RoundTrip.o
// RUN: %target-build-swift -g -static -emit-module-path %t/RoundTrip.swiftmodule -emit-module -emit-library -module-name RoundTrip -o %t/%target-static-library-name(RoundTrip) %S/Inputs/RoundTrip/RoundTrip.swift %t/RoundTrip.o
// RUN: echo "// AUTOGENERATED" > %t/all-tests.swift
// RUN: for module in %S/Inputs/testcases/*.swift; do modname=$(basename $module .swift); echo "import $modname" >> %t/all-tests.swift; done
// RUN: echo "func runAllTests() throws {" >> %t/all-tests.swift
// RUN: for module in %S/Inputs/testcases/*.swift; do modname=$(basename $module .swift); %target-build-swift -g -static -emit-module-path %t/$modname.swiftmodule -emit-module -emit-library -module-name $modname -o %t/%target-static-library-name($modname) -I%t -L%t $module -lRoundTrip; echo " print(\"--- $modname\")" >> %t/all-tests.swift; echo " $modname.test()" >> %t/all-tests.swift; echo " print(\"\")" >> %t/all-tests.swift; echo "-l$modname" >> %t/link.txt; done
// RUN: echo "}" >> %t/all-tests.swift
// RUN: %target-build-swift -g -I%t -o %t/round-trip %s %t/all-tests.swift -L%t -L%swift_obj_root/lib -L%swift_obj_root/lib/swift %target-cxx-lib $(cat %t/link.txt) -lRoundTrip -lswiftDemangling -lswiftReflection
// RUN: %target-codesign %t/round-trip
// RUN: %target-run %t/round-trip | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: shell
// CHECK-NOT: FAIL
@main
struct Test {
static func main() throws {
try runAllTests()
}
}

View File

@@ -877,13 +877,7 @@ def use_interpreter_for_simple_runs():
target_specific_module_triple = config.variant_triple target_specific_module_triple = config.variant_triple
target_future = target_specific_module_triple target_future = target_specific_module_triple
config.target_run = '' config.target_run = ""
config.target_rtti_opt = '-fno-rtti'
config.target_pic_opt = ''
config.target_cxx_lib = '-lc++'
config.target_msvc_runtime_opt = ''
config.target_static_library_prefix = 'lib'
config.target_static_library_suffix = '.a'
if run_vendor == 'apple': if run_vendor == 'apple':
target_specific_module_triple = '{}-apple-{}'.format( target_specific_module_triple = '{}-apple-{}'.format(
@@ -1205,16 +1199,9 @@ elif run_os in ['windows-msvc']:
config.target_object_format = 'coff' config.target_object_format = 'coff'
config.target_shared_library_prefix = '' config.target_shared_library_prefix = ''
config.target_shared_library_suffix = '.dll' config.target_shared_library_suffix = '.dll'
config.target_static_library_prefix = ''
config.target_static_library_suffix = '.lib'
config.target_sdk_name = 'windows' config.target_sdk_name = 'windows'
config.target_runtime = 'native' config.target_runtime = 'native'
config.target_cc_options = "" config.target_cc_options = ""
config.target_rtti_opt = "-frtti"
config.target_cxx_lib = ""
config.target_msvc_runtime_opt = '-%s -D_MT' % config.swift_stdlib_msvc_runtime
if 'D' in config.swift_stdlib_msvc_runtime:
config.target_msvc_runtime_opt += ' -D_DLL'
config.target_build_swift = \ config.target_build_swift = \
('%r -target %s %s %s %s %s -libc %s' % \ ('%r -target %s %s %s %s %s -libc %s' % \
@@ -1284,10 +1271,6 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
(kIsAndroid and run_os in ['linux-android', 'linux-androideabi'])): (kIsAndroid and run_os in ['linux-android', 'linux-androideabi'])):
# Running lit and the compiler on Android itself is more like running on Linux, # Running lit and the compiler on Android itself is more like running on Linux,
# ie the NDK and adb aren't needed, so use this instead. # ie the NDK and adb aren't needed, so use this instead.
config.target_cxx_lib = "-lstdc++"
config.target_pic_opt = "-fPIC"
# Linux/FreeBSD/Cygwin/Android # Linux/FreeBSD/Cygwin/Android
if run_os == 'windows-cygnus': if run_os == 'windows-cygnus':
lit_config.note("Testing Cygwin " + config.variant_triple) lit_config.note("Testing Cygwin " + config.variant_triple)
@@ -1430,9 +1413,6 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
result = kwards["aarch64"] result = kwards["aarch64"]
return result return result
config.target_cxx_lib = "-lstdc++"
config.target_pic_opt = "-fPIC"
ndk_platform_tuple = get_architecture_value(armv7="armeabi-v7a", ndk_platform_tuple = get_architecture_value(armv7="armeabi-v7a",
aarch64="arm64-v8a") aarch64="arm64-v8a")
ndk_platform_triple = get_architecture_value(armv7="arm-linux-androideabi", ndk_platform_triple = get_architecture_value(armv7="arm-linux-androideabi",
@@ -2036,12 +2016,6 @@ config.substitutions.append(('%target-swiftxx-frontend', '%s -enable-cxx-interop
config.substitutions.append(('%target-runtime', config.target_runtime)) config.substitutions.append(('%target-runtime', config.target_runtime))
config.substitutions.append(('%target-rtti-opt', config.target_rtti_opt))
config.substitutions.append(('%target-cxx-lib', config.target_cxx_lib))
config.substitutions.append(('%target-pic-opt', config.target_pic_opt))
config.substitutions.append(('%target-msvc-runtime-opt',
config.target_msvc_runtime_opt))
config.substitutions.append(('%target-typecheck-verify-swift', config.target_parse_verify_swift)) config.substitutions.append(('%target-typecheck-verify-swift', config.target_parse_verify_swift))
config.substitutions.append(('%target-swift-emit-silgen\(mock-sdk:([^)]+)\)', config.substitutions.append(('%target-swift-emit-silgen\(mock-sdk:([^)]+)\)',
@@ -2187,10 +2161,6 @@ config.substitutions.insert(0, ('%target-library-name\(([^)]+)\)',
SubstituteCaptures(r'%s\1%s' % ( SubstituteCaptures(r'%s\1%s' % (
escape_for_substitute_captures(config.target_shared_library_prefix), escape_for_substitute_captures(config.target_shared_library_prefix),
escape_for_substitute_captures(config.target_shared_library_suffix))))) escape_for_substitute_captures(config.target_shared_library_suffix)))))
config.substitutions.insert(0, ('%target-static-library-name\(([^)]+)\)',
SubstituteCaptures(r'%s\1%s' % (
escape_for_substitute_captures(config.target_static_library_prefix),
escape_for_substitute_captures(config.target_static_library_suffix)))))
config.substitutions.append(('%target-rpath\(([^)]+)\)', config.substitutions.append(('%target-rpath\(([^)]+)\)',
SubstituteCaptures(config.target_add_rpath))) SubstituteCaptures(config.target_add_rpath)))