mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Mangle imported declarations using their C names.
This makes them consistent no matter what shenanigans are pulled by the importer, particularly NS_ENUM vs. NS_OPTIONS and NS_SWIFT_NAME. The 'NSErrorDomain' API note /nearly/ works with this, but the synthesized error struct is still mangled as a Swift declaration, which means it's not rename-stable. See follow-up commits. The main place where this still falls down is NS_STRING_ENUM: when this is applied, a typedef is imported as a unique struct, but without it it's just a typealias for the underlying type. There's also still a problem with synthesized conformances, which have a module mangled into the witness table symbol even though that symbol is linkonce_odr. rdar://problem/31616162
This commit is contained in:
@@ -414,7 +414,7 @@ protected:
|
||||
NodePointer popModule();
|
||||
NodePointer popContext();
|
||||
NodePointer popTypeAndGetChild();
|
||||
NodePointer popTypeAndGetNominal();
|
||||
NodePointer popTypeAndGetAnyGeneric();
|
||||
NodePointer demangleBuiltinType();
|
||||
NodePointer demangleAnyGenericType(Node::Kind kind);
|
||||
NodePointer demangleExtensionContext();
|
||||
|
||||
@@ -106,7 +106,9 @@ class TypeDecoder {
|
||||
return decodeMangledType(Node->getChild(0));
|
||||
case NodeKind::Class:
|
||||
case NodeKind::Enum:
|
||||
case NodeKind::Structure: {
|
||||
case NodeKind::Structure:
|
||||
case NodeKind::TypeAlias: // This can show up for imported Clang decls.
|
||||
{
|
||||
BuiltNominalTypeDecl typeDecl = BuiltNominalTypeDecl();
|
||||
BuiltType parent = BuiltType();
|
||||
if (!decodeMangledNominalType(Node, typeDecl, parent))
|
||||
|
||||
@@ -226,6 +226,7 @@ public:
|
||||
bool isEnum() const;
|
||||
bool isClass() const;
|
||||
bool isProtocol() const;
|
||||
bool isAlias() const;
|
||||
|
||||
bool isErrorProtocol() const {
|
||||
return MangledName == "s5ErrorP";
|
||||
|
||||
@@ -1171,35 +1171,26 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn) {
|
||||
/// Mangle the context of the given declaration as a <context.
|
||||
/// This is the top-level entrypoint for mangling <context>.
|
||||
void ASTMangler::appendContextOf(const ValueDecl *decl) {
|
||||
auto clangDecl = decl->getClangDecl();
|
||||
|
||||
// Declarations provided provided by a C module have a special context
|
||||
// mangling.
|
||||
// Declarations provided by a C module have a special context mangling.
|
||||
// known-context ::= 'So'
|
||||
if (isa<ClassDecl>(decl) && clangDecl) {
|
||||
assert(isa<clang::ObjCInterfaceDecl>(clangDecl) ||
|
||||
isa<clang::TypedefDecl>(clangDecl));
|
||||
return appendOperator("So");
|
||||
}
|
||||
|
||||
if (isa<ProtocolDecl>(decl) && clangDecl) {
|
||||
assert(isa<clang::ObjCProtocolDecl>(clangDecl));
|
||||
return appendOperator("So");
|
||||
}
|
||||
|
||||
//
|
||||
// Also handle top-level imported declarations that don't have corresponding
|
||||
// Clang decls. Check getKind() directly to avoid a layering dependency.
|
||||
// known-context ::= 'SC'
|
||||
if (auto file = dyn_cast<FileUnit>(decl->getDeclContext())) {
|
||||
if (file->getKind() == FileUnitKind::ClangModule) {
|
||||
// FIXME: Import-as-member Clang decls should appear under 'So' as well,
|
||||
// rather than under their current parent.
|
||||
if (clangDecl)
|
||||
if (decl->getClangDecl())
|
||||
return appendOperator("So");
|
||||
return appendOperator("SC");
|
||||
}
|
||||
}
|
||||
|
||||
// Nested types imported from C should also get use the special "So" context.
|
||||
if (isa<TypeDecl>(decl))
|
||||
if (auto *clangDecl = decl->getClangDecl())
|
||||
if (clangDecl->getDeclContext()->isTranslationUnit())
|
||||
return appendOperator("So");
|
||||
|
||||
// Just mangle the decl's DC.
|
||||
appendContext(decl->getDeclContext());
|
||||
}
|
||||
@@ -1406,7 +1397,11 @@ void ASTMangler::appendModule(const ModuleDecl *module) {
|
||||
/// Mangle the name of a protocol as a substitution candidate.
|
||||
void ASTMangler::appendProtocolName(const ProtocolDecl *protocol) {
|
||||
appendContextOf(protocol);
|
||||
appendDeclName(protocol);
|
||||
auto *clangDecl = protocol->getClangDecl();
|
||||
if (auto *clangProto = cast_or_null<clang::ObjCProtocolDecl>(clangDecl))
|
||||
appendIdentifier(clangProto->getName());
|
||||
else
|
||||
appendDeclName(protocol);
|
||||
}
|
||||
|
||||
void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl) {
|
||||
@@ -1430,28 +1425,53 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl) {
|
||||
return;
|
||||
|
||||
appendContextOf(decl);
|
||||
appendDeclName(decl);
|
||||
|
||||
switch (decl->getKind()) {
|
||||
default:
|
||||
llvm_unreachable("not a nominal type");
|
||||
// Always use Clang names for imported Clang declarations.
|
||||
auto *clangDecl = dyn_cast_or_null<clang::NamedDecl>(decl->getClangDecl());
|
||||
if (clangDecl && !clangDecl->getName().empty()) {
|
||||
appendIdentifier(clangDecl->getName());
|
||||
// The important distinctions to maintain here are Objective-C's various
|
||||
// namespaces: protocols, tags (struct/enum/union), and unqualified names.
|
||||
// We continue to mangle "class" the standard Swift way because it feels
|
||||
// weird to call that an alias, but they're really in the same namespace.
|
||||
if (isa<clang::ObjCInterfaceDecl>(clangDecl)) {
|
||||
appendOperator("C");
|
||||
} else if (isa<clang::ObjCProtocolDecl>(clangDecl)) {
|
||||
appendOperator("P");
|
||||
} else if (isa<clang::TagDecl>(clangDecl)) {
|
||||
// Note: This includes enums, but that's okay. A Clang enum is not always
|
||||
// imported as a Swift enum.
|
||||
appendOperator("V");
|
||||
} else if (isa<clang::TypedefNameDecl>(clangDecl)) {
|
||||
appendOperator("a");
|
||||
} else {
|
||||
llvm_unreachable("unknown imported Clang type");
|
||||
}
|
||||
} else {
|
||||
appendDeclName(decl);
|
||||
|
||||
case DeclKind::TypeAlias:
|
||||
appendOperator("a");
|
||||
break;
|
||||
case DeclKind::Protocol:
|
||||
appendOperator("P");
|
||||
break;
|
||||
case DeclKind::Class:
|
||||
appendOperator("C");
|
||||
break;
|
||||
case DeclKind::Enum:
|
||||
appendOperator("O");
|
||||
break;
|
||||
case DeclKind::Struct:
|
||||
appendOperator("V");
|
||||
break;
|
||||
switch (decl->getKind()) {
|
||||
default:
|
||||
llvm_unreachable("not a nominal type");
|
||||
|
||||
case DeclKind::TypeAlias:
|
||||
appendOperator("a");
|
||||
break;
|
||||
case DeclKind::Protocol:
|
||||
appendOperator("P");
|
||||
break;
|
||||
case DeclKind::Class:
|
||||
appendOperator("C");
|
||||
break;
|
||||
case DeclKind::Enum:
|
||||
appendOperator("O");
|
||||
break;
|
||||
case DeclKind::Struct:
|
||||
appendOperator("V");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addSubstitution(key.getPointer());
|
||||
}
|
||||
|
||||
|
||||
@@ -56,12 +56,13 @@ static bool isContext(Node::Kind kind) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool isNominal(Node::Kind kind) {
|
||||
static bool isAnyGeneric(Node::Kind kind) {
|
||||
switch (kind) {
|
||||
case Node::Kind::Structure:
|
||||
case Node::Kind::Class:
|
||||
case Node::Kind::Enum:
|
||||
case Node::Kind::Protocol:
|
||||
case Node::Kind::TypeAlias:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -765,9 +766,9 @@ NodePointer Demangler::popTypeAndGetChild() {
|
||||
return Ty->getFirstChild();
|
||||
}
|
||||
|
||||
NodePointer Demangler::popTypeAndGetNominal() {
|
||||
NodePointer Demangler::popTypeAndGetAnyGeneric() {
|
||||
NodePointer Child = popTypeAndGetChild();
|
||||
if (Child && isNominal(Child->getKind()))
|
||||
if (Child && isAnyGeneric(Child->getKind()))
|
||||
return Child;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -855,7 +856,7 @@ NodePointer Demangler::demangleAnyGenericType(Node::Kind kind) {
|
||||
NodePointer Demangler::demangleExtensionContext() {
|
||||
NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature);
|
||||
NodePointer Module = popModule();
|
||||
NodePointer Type = popTypeAndGetNominal();
|
||||
NodePointer Type = popTypeAndGetAnyGeneric();
|
||||
NodePointer Ext = createWithChildren(Node::Kind::Extension, Module, Type);
|
||||
if (GenSig)
|
||||
Ext = addChild(Ext, GenSig);
|
||||
@@ -1063,7 +1064,7 @@ NodePointer Demangler::demangleBoundGenericType() {
|
||||
if (!popNode(Node::Kind::FirstElementMarker))
|
||||
return nullptr;
|
||||
}
|
||||
NodePointer Nominal = popTypeAndGetNominal();
|
||||
NodePointer Nominal = popTypeAndGetAnyGeneric();
|
||||
NodePointer NTy = createType(demangleBoundGenericArgs(Nominal, TypeListList, 0));
|
||||
addSubstitution(NTy);
|
||||
return NTy;
|
||||
@@ -1261,7 +1262,7 @@ NodePointer Demangler::demangleMetatype() {
|
||||
popProtocolConformance());
|
||||
case 'C': {
|
||||
NodePointer Ty = popNode(Node::Kind::Type);
|
||||
if (!Ty || !isNominal(Ty->getChild(0)->getKind()))
|
||||
if (!Ty || !isAnyGeneric(Ty->getChild(0)->getKind()))
|
||||
return nullptr;
|
||||
return createWithChild(Node::Kind::ReflectionMetadataSuperclassDescriptor,
|
||||
Ty->getChild(0));
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "swift/AST/TypeRepr.h"
|
||||
#include "swift/Basic/Mangler.h"
|
||||
#include "swift/ClangImporter/ClangImporter.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
// TODO: Develop a proper interface for this.
|
||||
#include "swift/AST/IRGenOptions.h"
|
||||
@@ -419,7 +420,8 @@ public:
|
||||
Type createObjCClassType(StringRef name) {
|
||||
Identifier ident = Ctx.getIdentifier(name);
|
||||
auto typeDecl =
|
||||
findForeignNominalTypeDecl(ident, Demangle::Node::Kind::Class);
|
||||
findForeignNominalTypeDecl(ident, ForeignModuleKind::Imported,
|
||||
Demangle::Node::Kind::Class);
|
||||
if (!typeDecl) return Type();
|
||||
return createNominalType(typeDecl, /*parent*/ Type());
|
||||
}
|
||||
@@ -462,13 +464,21 @@ private:
|
||||
DeclContext *findDeclContext(const Demangle::NodePointer &node);
|
||||
ModuleDecl *findModule(const Demangle::NodePointer &node);
|
||||
Demangle::NodePointer findModuleNode(const Demangle::NodePointer &node);
|
||||
bool isForeignModule(const Demangle::NodePointer &node);
|
||||
|
||||
enum class ForeignModuleKind {
|
||||
Imported,
|
||||
SynthesizedByImporter
|
||||
};
|
||||
|
||||
Optional<ForeignModuleKind>
|
||||
getForeignModuleKind(const Demangle::NodePointer &node);
|
||||
|
||||
NominalTypeDecl *findNominalTypeDecl(DeclContext *dc,
|
||||
Identifier name,
|
||||
Identifier privateDiscriminator,
|
||||
Demangle::Node::Kind kind);
|
||||
NominalTypeDecl *findForeignNominalTypeDecl(Identifier name,
|
||||
ForeignModuleKind lookupKind,
|
||||
Demangle::Node::Kind kind);
|
||||
|
||||
Type checkTypeRepr(TypeRepr *repr) {
|
||||
@@ -558,15 +568,19 @@ RemoteASTTypeBuilder::findModuleNode(const Demangle::NodePointer &node) {
|
||||
return findModuleNode(child->getFirstChild());
|
||||
}
|
||||
|
||||
bool RemoteASTTypeBuilder::isForeignModule(const Demangle::NodePointer &node) {
|
||||
Optional<RemoteASTTypeBuilder::ForeignModuleKind>
|
||||
RemoteASTTypeBuilder::getForeignModuleKind(const Demangle::NodePointer &node) {
|
||||
if (node->getKind() == Demangle::Node::Kind::DeclContext)
|
||||
return isForeignModule(node->getFirstChild());
|
||||
return getForeignModuleKind(node->getFirstChild());
|
||||
|
||||
if (node->getKind() != Demangle::Node::Kind::Module)
|
||||
return false;
|
||||
return None;
|
||||
|
||||
return (node->getText() == MANGLING_MODULE_OBJC ||
|
||||
node->getText() == MANGLING_MODULE_CLANG_IMPORTER);
|
||||
return llvm::StringSwitch<Optional<ForeignModuleKind>>(node->getText())
|
||||
.Case(MANGLING_MODULE_OBJC, ForeignModuleKind::Imported)
|
||||
.Case(MANGLING_MODULE_CLANG_IMPORTER,
|
||||
ForeignModuleKind::SynthesizedByImporter)
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
DeclContext *
|
||||
@@ -582,7 +596,8 @@ RemoteASTTypeBuilder::findDeclContext(const Demangle::NodePointer &node) {
|
||||
case Demangle::Node::Kind::Class:
|
||||
case Demangle::Node::Kind::Enum:
|
||||
case Demangle::Node::Kind::Protocol:
|
||||
case Demangle::Node::Kind::Structure: {
|
||||
case Demangle::Node::Kind::Structure:
|
||||
case Demangle::Node::Kind::TypeAlias: {
|
||||
const auto &declNameNode = node->getChild(1);
|
||||
|
||||
// Handle local declarations.
|
||||
@@ -620,12 +635,13 @@ RemoteASTTypeBuilder::findDeclContext(const Demangle::NodePointer &node) {
|
||||
DeclContext *dc = findDeclContext(node->getChild(0));
|
||||
if (!dc) {
|
||||
// Do some backup logic for foreign type declarations.
|
||||
if (privateDiscriminator.empty() &&
|
||||
isForeignModule(node->getChild(0))) {
|
||||
return findForeignNominalTypeDecl(name, node->getKind());
|
||||
} else {
|
||||
return nullptr;
|
||||
if (privateDiscriminator.empty()) {
|
||||
if (auto foreignModuleKind = getForeignModuleKind(node->getChild(0))) {
|
||||
return findForeignNominalTypeDecl(name, foreignModuleKind.getValue(),
|
||||
node->getKind());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return findNominalTypeDecl(dc, name, privateDiscriminator, node->getKind());
|
||||
@@ -675,6 +691,7 @@ RemoteASTTypeBuilder::findNominalTypeDecl(DeclContext *dc,
|
||||
|
||||
NominalTypeDecl *
|
||||
RemoteASTTypeBuilder::findForeignNominalTypeDecl(Identifier name,
|
||||
ForeignModuleKind foreignKind,
|
||||
Demangle::Node::Kind kind) {
|
||||
// Check to see if we have an importer loaded.
|
||||
auto importer = static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
|
||||
@@ -690,11 +707,9 @@ RemoteASTTypeBuilder::findForeignNominalTypeDecl(Identifier name,
|
||||
|
||||
void foundDecl(ValueDecl *decl, DeclVisibilityKind reason) override {
|
||||
if (HadError) return;
|
||||
auto typeDecl = getAcceptableNominalTypeCandidate(decl, ExpectedKind);
|
||||
if (!typeDecl) return;
|
||||
if (typeDecl == Result) return;
|
||||
if (decl == Result) return;
|
||||
if (!Result) {
|
||||
Result = typeDecl;
|
||||
Result = cast<NominalTypeDecl>(decl);
|
||||
} else {
|
||||
HadError = true;
|
||||
Result = nullptr;
|
||||
@@ -702,7 +717,36 @@ RemoteASTTypeBuilder::findForeignNominalTypeDecl(Identifier name,
|
||||
}
|
||||
} consumer(kind);
|
||||
|
||||
importer->lookupValue(name, consumer);
|
||||
switch (foreignKind) {
|
||||
case ForeignModuleKind::SynthesizedByImporter:
|
||||
importer->lookupValue(name, consumer);
|
||||
if (consumer.Result)
|
||||
consumer.Result = getAcceptableNominalTypeCandidate(consumer.Result,kind);
|
||||
break;
|
||||
case ForeignModuleKind::Imported: {
|
||||
ClangTypeKind lookupKind;
|
||||
switch (kind) {
|
||||
case Demangle::Node::Kind::Protocol:
|
||||
lookupKind = ClangTypeKind::ObjCProtocol;
|
||||
break;
|
||||
case Demangle::Node::Kind::Class:
|
||||
lookupKind = ClangTypeKind::ObjCClass;
|
||||
break;
|
||||
case Demangle::Node::Kind::TypeAlias:
|
||||
lookupKind = ClangTypeKind::Typedef;
|
||||
break;
|
||||
case Demangle::Node::Kind::Structure:
|
||||
case Demangle::Node::Kind::Enum:
|
||||
lookupKind = ClangTypeKind::Tag;
|
||||
break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
importer->lookupTypeDecl(name.str(), lookupKind, [&](TypeDecl *found) {
|
||||
consumer.foundDecl(found, DeclVisibilityKind::VisibleAtTopLevel);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return consumer.Result;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ public:
|
||||
printHeader("protocol");
|
||||
mangledName = Demangle::dropSwiftManglingPrefix(mangledName);
|
||||
}
|
||||
else if (N->isAlias())
|
||||
printHeader("alias");
|
||||
else
|
||||
printHeader("nominal");
|
||||
auto demangled = Demangle::demangleTypeAsString(mangledName);
|
||||
@@ -462,6 +464,17 @@ bool isProtocol(Demangle::NodePointer Node) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isAlias(Demangle::NodePointer Node) {
|
||||
switch (Node->getKind()) {
|
||||
case Demangle::Node::Kind::Type:
|
||||
return isAlias(Node->getChild(0));
|
||||
case Demangle::Node::Kind::TypeAlias:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
||||
bool NominalTypeTrait::isStruct() const {
|
||||
@@ -470,14 +483,12 @@ bool NominalTypeTrait::isStruct() const {
|
||||
return ::isStruct(Demangled);
|
||||
}
|
||||
|
||||
|
||||
bool NominalTypeTrait::isEnum() const {
|
||||
Demangle::Demangler Dem;
|
||||
Demangle::NodePointer Demangled = Dem.demangleType(MangledName);
|
||||
return ::isEnum(Demangled);
|
||||
}
|
||||
|
||||
|
||||
bool NominalTypeTrait::isClass() const {
|
||||
Demangle::Demangler Dem;
|
||||
Demangle::NodePointer Demangled = Dem.demangleType(MangledName);
|
||||
@@ -491,6 +502,12 @@ bool NominalTypeTrait::isProtocol() const {
|
||||
return ::isProtocol(Demangled);
|
||||
}
|
||||
|
||||
bool NominalTypeTrait::isAlias() const {
|
||||
Demangle::Demangler Dem;
|
||||
Demangle::NodePointer Demangled = Dem.demangleType(MangledName);
|
||||
return ::isAlias(Demangled);
|
||||
}
|
||||
|
||||
/// Visitor class to set the WasAbstract flag of any MetatypeTypeRefs
|
||||
/// contained in the given type.
|
||||
class ThickenMetatype
|
||||
|
||||
@@ -229,7 +229,7 @@ static const WitnessTable *getNSErrorConformanceToError() {
|
||||
// Swift source.
|
||||
|
||||
auto TheWitnessTable = SWIFT_LAZY_CONSTANT(dlsym(RTLD_DEFAULT,
|
||||
MANGLE_AS_STRING(MANGLE_SYM(So7CFErrorCs5Error10FoundationWP))));
|
||||
MANGLE_AS_STRING(MANGLE_SYM(So10CFErrorRefas5Error10FoundationWP))));
|
||||
assert(TheWitnessTable &&
|
||||
"Foundation overlay not loaded, or 'CFError : Error' conformance "
|
||||
"not available");
|
||||
|
||||
@@ -251,14 +251,14 @@ func testRenamedOptionyEnum() {
|
||||
#if !swift(>=4)
|
||||
|
||||
func useSwift3Name(_: ImportantCStruct) {}
|
||||
// CHECK-SILGEN-3: sil hidden @$S9versioned13useSwift3NameyySo20VeryImportantCStructVF
|
||||
// CHECK-SILGEN-3: sil hidden @$S9versioned13useSwift3NameyySo11SomeCStructVF
|
||||
|
||||
func useNewlyNested(_: InnerInSwift4) {}
|
||||
// CHECK-SILGEN-3: sil hidden @$S9versioned14useNewlyNestedyySo5OuterV5InnerVF
|
||||
// CHECK-SILGEN-3: sil hidden @$S9versioned14useNewlyNestedyySo13InnerInSwift4VF
|
||||
#endif
|
||||
|
||||
func useSwift4Name(_: VeryImportantCStruct) {}
|
||||
// CHECK-SILGEN: sil hidden @$S9versioned13useSwift4NameyySo20VeryImportantCStructVF
|
||||
// CHECK-SILGEN: sil hidden @$S9versioned13useSwift4NameyySo11SomeCStructVF
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public func testTopLevel() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo12__PrivFooSubCMa{{.*}} {
|
||||
// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo10PrivFooSubCMa{{.*}} {
|
||||
// CHECK: %objc_class** @"OBJC_CLASS_REF_$_PrivFooSub"
|
||||
// CHECK: }
|
||||
|
||||
|
||||
@@ -4,35 +4,35 @@
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// CHECK: [[TYPE:%swift.type]] = type
|
||||
// CHECK: [[REFRIGERATOR:%TSo14CCRefrigeratorC]] = type
|
||||
// CHECK: [[MUTABLE_REFRIGERATOR:%TSo21CCMutableRefrigeratorC]] = type
|
||||
// CHECK: [[REFRIGERATOR:%TSo17CCRefrigeratorRefa]] = type
|
||||
// CHECK: [[MUTABLE_REFRIGERATOR:%TSo24CCMutableRefrigeratorRefa]] = type
|
||||
// CHECK: [[OBJC:%objc_object]] = type
|
||||
|
||||
// CHECK: [[REFRIGERATOR_NAME:@.*]] = private constant [20 x i8] c"So14CCRefrigeratorC\00"
|
||||
// CHECK: [[REFRIGERATOR_NAME:@.*]] = private constant [23 x i8] c"So17CCRefrigeratorRefa\00"
|
||||
|
||||
// CHECK-32: @"$SSo14CCRefrigeratorCN" = linkonce_odr hidden global <{ {{.*}} }> <{
|
||||
// CHECK-32: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
|
||||
// CHECK-32-SAME: [[REFRIGERATOR_NAME]] to i32
|
||||
// CHECK-32-SAME: i32 0,
|
||||
// CHECK-32-SAME: i8** @"$SBOWV", i32 16, {{.*}}"$SSo14CCRefrigeratorCMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
|
||||
// CHECK-32-SAME: i8** @"$SBOWV", i32 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
|
||||
|
||||
// CHECK-64: @"$SSo14CCRefrigeratorCN" = linkonce_odr hidden global <{ {{.*}} }> <{
|
||||
// CHECK-64: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
|
||||
// CHECK-64-SAME: i32 0,
|
||||
// CHECK-64-SAME: i32 trunc {{.*}} [[REFRIGERATOR_NAME]] to i64
|
||||
// CHECK-64-SAME: i64 0,
|
||||
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo14CCRefrigeratorCMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
|
||||
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
|
||||
|
||||
// CHECK: [[MUTABLE_REFRIGERATOR_NAME:@.*]] = private constant [27 x i8] c"So21CCMutableRefrigeratorC\00"
|
||||
// CHECK: [[MUTABLE_REFRIGERATOR_NAME:@.*]] = private constant [30 x i8] c"So24CCMutableRefrigeratorRefa\00"
|
||||
|
||||
// CHECK-64: @"$SSo21CCMutableRefrigeratorCMn" = linkonce_odr hidden constant
|
||||
// CHECK-64: @"$SSo24CCMutableRefrigeratorRefaMn" = linkonce_odr hidden constant
|
||||
// CHECK-64-SAME: [[MUTABLE_REFRIGERATOR_NAME]]
|
||||
// CHECK-64-SAME: @get_field_types_CCMutableRefrigerator
|
||||
// CHECK-64-SAME: i16 1, i16 2, i32 0 }>
|
||||
|
||||
// CHECK-64: @"$SSo21CCMutableRefrigeratorCN" = linkonce_odr hidden global <{ {{.*}} }> <{
|
||||
// CHECK-64: @"$SSo24CCMutableRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
|
||||
// CHECK-64-SAME: @initialize_metadata_CCMutableRefrigerator
|
||||
// CHECK-64-SAME: i32 trunc {{.*}} [[MUTABLE_REFRIGERATOR_NAME]] to i64
|
||||
// CHECK-64-SAME: i64 1,
|
||||
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo21CCMutableRefrigeratorCMn", [[TYPE]]* bitcast{{.*}}@"$SSo14CCRefrigeratorCN{{.*}} to %swift.type*), i8* null, i8* null, i8* null }>
|
||||
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo24CCMutableRefrigeratorRefaMn", [[TYPE]]* bitcast{{.*}}@"$SSo17CCRefrigeratorRefaN{{.*}} to %swift.type*), i8* null, i8* null, i8* null }>
|
||||
|
||||
sil_stage canonical
|
||||
|
||||
@@ -52,16 +52,16 @@ bb0(%0 : $CCRefrigerator, %1: $CCMutableRefrigerator):
|
||||
|
||||
// CHECK: define{{( protected)?}} swiftcc void @call_generic([[REFRIGERATOR]]*, [[MUTABLE_REFRIGERATOR]]*) {{.*}} {
|
||||
// CHECK: [[T0:%.*]] = bitcast [[REFRIGERATOR]]* %0 to [[OBJC]]*
|
||||
// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo14CCRefrigeratorCMa"()
|
||||
// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"()
|
||||
// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T1]])
|
||||
// CHECK: [[T0:%.*]] = bitcast [[MUTABLE_REFRIGERATOR]]* %1 to [[OBJC]]*
|
||||
// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo21CCMutableRefrigeratorCMa"()
|
||||
// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo24CCMutableRefrigeratorRefaMa"()
|
||||
// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T1]])
|
||||
// CHECK-NEXT: ret void
|
||||
|
||||
// CHECK: define linkonce_odr hidden [[TYPE]]* @"$SSo14CCRefrigeratorCMa"()
|
||||
// CHECK-32: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo14CCRefrigeratorCN" to i8*), i32 12) to [[TYPE]]*))
|
||||
// CHECK-64: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo14CCRefrigeratorCN" to i8*), i64 24) to [[TYPE]]*))
|
||||
// CHECK: define linkonce_odr hidden [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"()
|
||||
// CHECK-32: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i32 12) to [[TYPE]]*))
|
||||
// CHECK-64: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i64 24) to [[TYPE]]*))
|
||||
|
||||
// CHECK: define private void @initialize_metadata_CCMutableRefrigerator(%swift.type*)
|
||||
// CHECK-64: [[T0:%.*]] = bitcast %swift.type* %0 to i8**
|
||||
|
||||
@@ -9,15 +9,15 @@ import Newtype
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// Witness table for synthesized ClosedEnums : _ObjectiveCBridgeable.
|
||||
// CHECK: @"$SSo10ClosedEnumVs21_ObjectiveCBridgeable7NewtypeWP" = linkonce_odr
|
||||
// CHECK: @"$SSo13SNTClosedEnumas21_ObjectiveCBridgeable7NewtypeWP" = linkonce_odr
|
||||
|
||||
// CHECK-LABEL: define swiftcc %TSo8NSStringC* @"$S7newtype14getErrorDomainSo0cD0VyF"()
|
||||
// CHECK-LABEL: define swiftcc %TSo8NSStringC* @"$S7newtype14getErrorDomainSo08SNTErrorD0ayF"()
|
||||
public func getErrorDomain() -> ErrorDomain {
|
||||
// CHECK: load %TSo8NSStringC*, %TSo8NSStringC** getelementptr inbounds (%TSo11ErrorDomainV, %TSo11ErrorDomainV* {{.*}}@SNTErrOne
|
||||
// CHECK: load %TSo8NSStringC*, %TSo8NSStringC** getelementptr inbounds (%TSo14SNTErrorDomaina, %TSo14SNTErrorDomaina* {{.*}}@SNTErrOne
|
||||
return .one
|
||||
}
|
||||
|
||||
// CHECK-LABEL: $S7newtype6getFooSo14NSNotificationC4NameVyF
|
||||
// CHECK-LABEL: $S7newtype6getFooSo18NSNotificationNameayF
|
||||
public func getFoo() -> NSNotification.Name {
|
||||
return NSNotification.Name.Foo
|
||||
// CHECK: load {{.*}} @FooNotification
|
||||
@@ -39,7 +39,7 @@ public func getGlobalNotification(_ x: Int) -> String {
|
||||
// CHECK: ret
|
||||
}
|
||||
|
||||
// CHECK-LABEL: $S7newtype17getCFNewTypeValue6useVarSo0cD0VSb_tF
|
||||
// CHECK-LABEL: $S7newtype17getCFNewTypeValue6useVarSo0cD0aSb_tF
|
||||
public func getCFNewTypeValue(useVar: Bool) -> CFNewType {
|
||||
if (useVar) {
|
||||
return CFNewType.MyCFNewTypeValue
|
||||
@@ -51,7 +51,7 @@ public func getCFNewTypeValue(useVar: Bool) -> CFNewType {
|
||||
// CHECK: ret
|
||||
}
|
||||
|
||||
// CHECK-LABEL: $S7newtype21getUnmanagedCFNewType6useVars0C0VySo8CFStringCGSb_tF
|
||||
// CHECK-LABEL: $S7newtype21getUnmanagedCFNewType6useVars0C0VySo11CFStringRefaGSb_tF
|
||||
public func getUnmanagedCFNewType(useVar: Bool) -> Unmanaged<CFString> {
|
||||
if (useVar) {
|
||||
return CFNewType.MyCFNewTypeValueUnaudited
|
||||
@@ -132,26 +132,26 @@ public func anchor() -> Bool {
|
||||
}
|
||||
|
||||
class ObjCTest {
|
||||
// CHECK-LABEL: define hidden %0* @"$S7newtype8ObjCTestC19optionalPassThroughySo11ErrorDomainVSgAGFTo"
|
||||
// CHECK-LABEL: define hidden %0* @"$S7newtype8ObjCTestC19optionalPassThroughySo14SNTErrorDomainaSgAGFTo"
|
||||
// CHECK: [[CASTED:%.+]] = ptrtoint %0* %2 to i{{32|64}}
|
||||
// CHECK: [[RESULT:%.+]] = call swiftcc i{{32|64}} @"$S7newtype8ObjCTestC19optionalPassThroughySo11ErrorDomainVSgAGF"(i{{32|64}} [[CASTED]], %T7newtype8ObjCTestC* swiftself {{%.+}})
|
||||
// CHECK: [[RESULT:%.+]] = call swiftcc i{{32|64}} @"$S7newtype8ObjCTestC19optionalPassThroughySo14SNTErrorDomainaSgAGF"(i{{32|64}} [[CASTED]], %T7newtype8ObjCTestC* swiftself {{%.+}})
|
||||
// CHECK: [[OPAQUE_RESULT:%.+]] = inttoptr i{{32|64}} [[RESULT]] to %0*
|
||||
// CHECK: ret %0* [[OPAQUE_RESULT]]
|
||||
// CHECK: {{^}$}}
|
||||
|
||||
// OPT-LABEL: define hidden %0* @"$S7newtype8ObjCTestC19optionalPassThroughySo11ErrorDomainVSgAGFTo"
|
||||
// OPT-LABEL: define hidden %0* @"$S7newtype8ObjCTestC19optionalPassThroughySo14SNTErrorDomainaSgAGFTo"
|
||||
// OPT: ret %0* %2
|
||||
// OPT: {{^}$}}
|
||||
@objc func optionalPassThrough(_ ed: ErrorDomain?) -> ErrorDomain? {
|
||||
return ed
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define hidden i32 @"$S7newtype8ObjCTestC18integerPassThroughySo5MyIntVAFFTo"
|
||||
// CHECK: [[RESULT:%.+]] = call swiftcc i32 @"$S7newtype8ObjCTestC18integerPassThroughySo5MyIntVAFF"(i32 %2, %T7newtype8ObjCTestC* swiftself {{%.+}})
|
||||
// CHECK-LABEL: define hidden i32 @"$S7newtype8ObjCTestC18integerPassThroughySo5MyIntaAFFTo"
|
||||
// CHECK: [[RESULT:%.+]] = call swiftcc i32 @"$S7newtype8ObjCTestC18integerPassThroughySo5MyIntaAFF"(i32 %2, %T7newtype8ObjCTestC* swiftself {{%.+}})
|
||||
// CHECK: ret i32 [[RESULT]]
|
||||
// CHECK: {{^}$}}
|
||||
|
||||
// OPT-LABEL: define hidden i32 @"$S7newtype8ObjCTestC18integerPassThroughySo5MyIntVAFFTo"
|
||||
// OPT-LABEL: define hidden i32 @"$S7newtype8ObjCTestC18integerPassThroughySo5MyIntaAFFTo"
|
||||
// OPT: ret i32 %2
|
||||
// OPT: {{^}$}}
|
||||
@objc func integerPassThrough(_ num: MyInt) -> MyInt {
|
||||
|
||||
@@ -71,7 +71,7 @@ entry(%0: $Subclass):
|
||||
unreachable
|
||||
}
|
||||
|
||||
sil @$S27objc_generic_class_metadata8SubclassC7optionsSQyACGs10DictionaryVySo13GenericOptionVypGSg_tcfcTo : $@convention(objc_method) (@owned Subclass, @owned NSDictionary) -> @owned Subclass {
|
||||
sil @$S27objc_generic_class_metadata8SubclassC7optionsSQyACGs10DictionaryVySo13GenericOptionaypGSg_tcfcTo : $@convention(objc_method) (@owned Subclass, @owned NSDictionary) -> @owned Subclass {
|
||||
entry(%0: $Subclass, %1: $NSDictionary):
|
||||
unreachable
|
||||
}
|
||||
|
||||
@@ -8,71 +8,71 @@
|
||||
import Foundation
|
||||
import gizmo
|
||||
|
||||
// CHECK: @"$SSo16NSRuncingOptionsOWV" = linkonce_odr hidden constant
|
||||
// CHECK: @"$SSo16NSRuncingOptionsOMn" = linkonce_odr hidden constant
|
||||
// CHECK: @"$SSo16NSRuncingOptionsON" = linkonce_odr hidden global
|
||||
// CHECK: @"$SSo28NeverActuallyMentionedByNameOs9Equatable5gizmoWP" = linkonce_odr hidden constant
|
||||
// CHECK: @"$SSo16NSRuncingOptionsVWV" = linkonce_odr hidden constant
|
||||
// CHECK: @"$SSo16NSRuncingOptionsVMn" = linkonce_odr hidden constant
|
||||
// CHECK: @"$SSo16NSRuncingOptionsVN" = linkonce_odr hidden global
|
||||
// CHECK: @"$SSo28NeverActuallyMentionedByNameVs9Equatable5gizmoWP" = linkonce_odr hidden constant
|
||||
|
||||
// CHECK-LABEL: define{{( protected)?}} i32 @main
|
||||
// CHECK: call %swift.type* @"$SSo16NSRuncingOptionsOMa"()
|
||||
// CHECK: call %swift.type* @"$SSo16NSRuncingOptionsVMa"()
|
||||
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_aSo16NSRuncingOptionsOyF"()
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_aSo16NSRuncingOptionsVyF"()
|
||||
// CHECK: ret i16 123
|
||||
func imported_enum_inject_a() -> NSRuncingOptions {
|
||||
return .mince
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_bSo16NSRuncingOptionsOyF"()
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_bSo16NSRuncingOptionsVyF"()
|
||||
// CHECK: ret i16 4567
|
||||
func imported_enum_inject_b() -> NSRuncingOptions {
|
||||
return .quinceSliced
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_cSo16NSRuncingOptionsOyF"()
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_cSo16NSRuncingOptionsVyF"()
|
||||
// CHECK: ret i16 5678
|
||||
func imported_enum_inject_c() -> NSRuncingOptions {
|
||||
return .quinceJulienned
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_dSo16NSRuncingOptionsOyF"()
|
||||
// CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_dSo16NSRuncingOptionsVyF"()
|
||||
// CHECK: ret i16 6789
|
||||
func imported_enum_inject_d() -> NSRuncingOptions {
|
||||
return .quinceDiced
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C17_inject_radixed_aSo16NSRadixedOptionsOyF"() {{.*}} {
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C17_inject_radixed_aSo16NSRadixedOptionsVyF"() {{.*}} {
|
||||
// -- octal 0755
|
||||
// CHECK: ret i32 493
|
||||
func imported_enum_inject_radixed_a() -> NSRadixedOptions {
|
||||
return .octal
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C17_inject_radixed_bSo16NSRadixedOptionsOyF"() {{.*}} {
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C17_inject_radixed_bSo16NSRadixedOptionsVyF"() {{.*}} {
|
||||
// -- hex 0xFFFF
|
||||
// CHECK: ret i32 65535
|
||||
func imported_enum_inject_radixed_b() -> NSRadixedOptions {
|
||||
return .hex
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C18_inject_negative_aSo17NSNegativeOptionsOyF"() {{.*}} {
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C18_inject_negative_aSo17NSNegativeOptionsVyF"() {{.*}} {
|
||||
// CHECK: ret i32 -1
|
||||
func imported_enum_inject_negative_a() -> NSNegativeOptions {
|
||||
return .foo
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C18_inject_negative_bSo17NSNegativeOptionsOyF"() {{.*}} {
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C18_inject_negative_bSo17NSNegativeOptionsVyF"() {{.*}} {
|
||||
// CHECK: ret i32 -2147483648
|
||||
func imported_enum_inject_negative_b() -> NSNegativeOptions {
|
||||
return .bar
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C27_inject_negative_unsigned_aSo25NSNegativeUnsignedOptionsOyF"() {{.*}} {
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C27_inject_negative_unsigned_aSo25NSNegativeUnsignedOptionsVyF"() {{.*}} {
|
||||
// CHECK: ret i32 -1
|
||||
func imported_enum_inject_negative_unsigned_a() -> NSNegativeUnsignedOptions {
|
||||
return .foo
|
||||
}
|
||||
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C27_inject_negative_unsigned_bSo25NSNegativeUnsignedOptionsOyF"() {{.*}} {
|
||||
// CHECK: define hidden swiftcc i32 @"$S12objc_ns_enum09imported_C27_inject_negative_unsigned_bSo25NSNegativeUnsignedOptionsVyF"() {{.*}} {
|
||||
// CHECK: ret i32 -2147483648
|
||||
func imported_enum_inject_negative_unsigned_b() -> NSNegativeUnsignedOptions {
|
||||
return .bar
|
||||
@@ -85,8 +85,8 @@ func test_enum_without_name_Equatable(_ obj: TestThatEnumType) -> Bool {
|
||||
func use_metadata<T>(_ t:T){}
|
||||
use_metadata(NSRuncingOptions.mince)
|
||||
|
||||
// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo16NSRuncingOptionsOMa"()
|
||||
// CHECK: call %swift.type* @swift_getForeignTypeMetadata({{.*}} @"$SSo16NSRuncingOptionsON" {{.*}}) [[NOUNWIND_READNONE:#[0-9]+]]
|
||||
// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo16NSRuncingOptionsVMa"()
|
||||
// CHECK: call %swift.type* @swift_getForeignTypeMetadata({{.*}} @"$SSo16NSRuncingOptionsVN" {{.*}}) [[NOUNWIND_READNONE:#[0-9]+]]
|
||||
|
||||
@objc enum ExportedToObjC: Int {
|
||||
case Foo = -1, Bar, Bas
|
||||
|
||||
@@ -8,7 +8,7 @@ import gizmo
|
||||
|
||||
sil @use_metatype : $@convention(thin) <T> (@thin T.Type) -> ()
|
||||
|
||||
// CHECK-LABEL: define swiftcc void @test(%TSo9InnerTypeC* swiftself, %swift.type* %Self, i8** %SelfWitnessTable)
|
||||
// CHECK-LABEL: define swiftcc void @test(%TSo014OuterTypeInnerB0C* swiftself, %swift.type* %Self, i8** %SelfWitnessTable)
|
||||
// CHECK: [[TMP:%.*]] = call %swift.type* @"$SSo9OuterTypeCMa"()
|
||||
// CHECK: call swiftcc void @use_metatype(%swift.type* [[TMP]])
|
||||
// CHECK: ret void
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
// CHECK: nsString: __C.NSString
|
||||
// CHECK: (class __C.NSString)
|
||||
|
||||
// CHECK: cfString: __C.CFString
|
||||
// CHECK: (class __C.CFString)
|
||||
// CHECK: cfString: __C.CFStringRef
|
||||
// CHECK: (alias __C.CFStringRef)
|
||||
|
||||
// CHECK: aBlock: @convention(block) () -> ()
|
||||
// CHECK: (function convention=block
|
||||
@@ -27,9 +27,9 @@
|
||||
// CHECK: (bound_generic_class TypesToReflect.GenericOC
|
||||
// CHECK: (class __C.NSString))
|
||||
|
||||
// CHECK: occfs: TypesToReflect.GenericOC<__C.CFString>
|
||||
// CHECK: occfs: TypesToReflect.GenericOC<__C.CFStringRef>
|
||||
// CHECK: (bound_generic_class TypesToReflect.GenericOC
|
||||
// CHECK: (class __C.CFString))
|
||||
// CHECK: (alias __C.CFStringRef))
|
||||
|
||||
// CHECK: TypesToReflect.GenericOC
|
||||
// CHECK: ------------------------
|
||||
@@ -48,7 +48,7 @@
|
||||
// CHECK: TypesToReflect.OP
|
||||
// CHECK: -----------------
|
||||
|
||||
// CHECK: __C.Bundle
|
||||
// CHECK: __C.NSBundle
|
||||
// CHECK: ----------
|
||||
// CHECK: __C.NSURL
|
||||
// CHECK: ---------
|
||||
@@ -77,7 +77,7 @@
|
||||
// CHECK-NEXT: ====================
|
||||
|
||||
// CHECK: - Capture types:
|
||||
// CHECK-NEXT: (class __C.Bundle)
|
||||
// CHECK-NEXT: (class __C.NSBundle)
|
||||
// CHECK-NEXT: (protocol_composition
|
||||
// CHECK-NEXT: (protocol __C.NSCoding))
|
||||
// CHECK-NEXT: - Metadata sources:
|
||||
|
||||
26
test/RemoteAST/Inputs/custom-modules/ErrorEnums.h
Normal file
26
test/RemoteAST/Inputs/custom-modules/ErrorEnums.h
Normal file
@@ -0,0 +1,26 @@
|
||||
@import Foundation;
|
||||
|
||||
NSString * const MyErrorDomain;
|
||||
typedef NS_ENUM(int, MyError) {
|
||||
MyErrorGood,
|
||||
MyErrorBad,
|
||||
} __attribute__((ns_error_domain(MyErrorDomain)));
|
||||
|
||||
NSString * const MyRenamedErrorDomain;
|
||||
typedef NS_ENUM(int, MyRenamedError) {
|
||||
MyRenamedErrorGood,
|
||||
MyRenamedErrorBad,
|
||||
} __attribute__((ns_error_domain(MyRenamedErrorDomain))) __attribute__((swift_name("RenamedError")));
|
||||
|
||||
|
||||
struct Wrapper {
|
||||
int unrelatedValue;
|
||||
};
|
||||
|
||||
// Not actually an error enum, since those can't be import-as-member'd right
|
||||
// now, but it can still hang with us.
|
||||
typedef NS_ENUM(int, MyMemberEnum) {
|
||||
MyMemberEnumA,
|
||||
MyMemberEnumB,
|
||||
} __attribute__((swift_name("Wrapper.MemberEnum")));
|
||||
|
||||
1
test/RemoteAST/Inputs/custom-modules/module.modulemap
Normal file
1
test/RemoteAST/Inputs/custom-modules/module.modulemap
Normal file
@@ -0,0 +1 @@
|
||||
module ErrorEnums { header "ErrorEnums.h" }
|
||||
@@ -1,12 +1,29 @@
|
||||
// RUN: %target-swift-remoteast-test -sdk %S/../IRGen/Inputs %s | %FileCheck %s
|
||||
// RUN: %target-swift-remoteast-test-with-sdk -I %S/../ClangImporter/Inputs/custom-modules -I %S/Inputs/custom-modules %s | %FileCheck %s
|
||||
|
||||
// REQUIRES: swift-remoteast-test
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
import Foundation
|
||||
import CoreCooling
|
||||
import ErrorEnums
|
||||
|
||||
@_silgen_name("printMetadataType")
|
||||
func printType(_: Any.Type)
|
||||
|
||||
printType(CCRefrigerator.self)
|
||||
// CHECK: found type: CCRefrigerator
|
||||
|
||||
printType(MyError.self)
|
||||
// CHECK: found type: MyError{{$}}
|
||||
|
||||
printType(MyError.Code.self)
|
||||
// CHECK: found type: MyError.Code{{$}}
|
||||
|
||||
printType(RenamedError.self)
|
||||
// CHECK: found type: RenamedError{{$}}
|
||||
|
||||
printType(RenamedError.Code.self)
|
||||
// CHECK: found type: RenamedError.Code{{$}}
|
||||
|
||||
printType(Wrapper.MemberEnum.self)
|
||||
// CHECK: found type: Wrapper.MemberEnum{{$}}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
- (void) anse;
|
||||
@end
|
||||
|
||||
__attribute__((swift_name("BetterAnsing")))
|
||||
@protocol NSBetterAnsing <NSAnsing>
|
||||
@end
|
||||
|
||||
@interface NSObject (NSAnsing)
|
||||
@property Class<NSAnsing> qualifiedClassProp;
|
||||
@end
|
||||
|
||||
@@ -39,7 +39,7 @@ public func foo(_ x: Double) {
|
||||
z = makeMetatype().init(value: x)
|
||||
|
||||
// CHECK: [[SELF_META:%.*]] = metatype $@thin Struct1.Type
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo7Struct1V5valueABSd_tcfCTcTO
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo10IAMStruct1V5valueABSd_tcfCTcTO
|
||||
// CHECK: [[A:%.*]] = apply [[THUNK]]([[SELF_META]])
|
||||
// CHECK: [[BORROWED_A:%.*]] = begin_borrow [[A]]
|
||||
// CHECK: [[A_COPY:%.*]] = copy_value [[BORROWED_A]]
|
||||
@@ -68,7 +68,7 @@ public func foo(_ x: Double) {
|
||||
|
||||
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
|
||||
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
|
||||
// CHECK: [[THUNK:%.*]] = function_ref [[THUNK_NAME:@\$SSo7Struct1V9translate7radiansABSd_tFTcTO]]
|
||||
// CHECK: [[THUNK:%.*]] = function_ref [[THUNK_NAME:@\$SSo10IAMStruct1V9translate7radiansABSd_tFTcTO]]
|
||||
// CHECK: [[C:%.*]] = apply [[THUNK]]([[ZVAL]])
|
||||
// CHECK: [[BORROWED_C:%.*]] = begin_borrow [[C]]
|
||||
// CHECK: [[C_COPY:%.*]] = copy_value [[BORROWED_C]]
|
||||
@@ -105,7 +105,7 @@ public func foo(_ x: Double) {
|
||||
|
||||
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
|
||||
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo7Struct1V5scaleyABSdFTcTO
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo10IAMStruct1V5scaleyABSdFTcTO
|
||||
// CHECK: [[F:%.*]] = apply [[THUNK]]([[ZVAL]])
|
||||
// CHECK: [[BORROWED_F:%.*]] = begin_borrow [[F]]
|
||||
// CHECK: [[F_COPY:%.*]] = copy_value [[BORROWED_F]]
|
||||
@@ -115,7 +115,7 @@ public func foo(_ x: Double) {
|
||||
// CHECK: destroy_value [[F_COPY]]
|
||||
// CHECK: end_borrow [[BORROWED_F]] from [[F]]
|
||||
z = f(x)
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo7Struct1V5scaleyABSdFTcTO
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo10IAMStruct1V5scaleyABSdFTcTO
|
||||
// CHECK: thin_to_thick_function [[THUNK]]
|
||||
let g = Struct1.scale
|
||||
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
|
||||
@@ -161,7 +161,7 @@ public func foo(_ x: Double) {
|
||||
// CHECK: apply [[FN]]()
|
||||
var y = Struct1.staticMethod()
|
||||
// CHECK: [[SELF:%.*]] = metatype
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo7Struct1V12staticMethods5Int32VyFZTcTO
|
||||
// CHECK: [[THUNK:%.*]] = function_ref @$SSo10IAMStruct1V12staticMethods5Int32VyFZTcTO
|
||||
// CHECK: [[I:%.*]] = apply [[THUNK]]([[SELF]])
|
||||
// CHECK: [[BORROWED_I:%.*]] = begin_borrow [[I]]
|
||||
// CHECK: [[I_COPY:%.*]] = copy_value [[BORROWED_I]]
|
||||
@@ -238,37 +238,37 @@ public func foo(_ x: Double) {
|
||||
}
|
||||
// CHECK: } // end sil function '$S10cf_members3foo{{[_0-9a-zA-Z]*}}F'
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo7Struct1V5valueABSd_tcfCTO
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo10IAMStruct1V5valueABSd_tcfCTO
|
||||
// CHECK: bb0([[X:%.*]] : @trivial $Double, [[SELF:%.*]] : @trivial $@thin Struct1.Type):
|
||||
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1CreateSimple
|
||||
// CHECK: [[RET:%.*]] = apply [[CFUNC]]([[X]])
|
||||
// CHECK: return [[RET]]
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo7Struct1V9translate7radiansABSd_tFTO
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo10IAMStruct1V9translate7radiansABSd_tFTO
|
||||
// CHECK: bb0([[X:%.*]] : @trivial $Double, [[SELF:%.*]] : @trivial $Struct1):
|
||||
// CHECK: store [[SELF]] to [trivial] [[TMP:%.*]] :
|
||||
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1Rotate
|
||||
// CHECK: [[RET:%.*]] = apply [[CFUNC]]([[TMP]], [[X]])
|
||||
// CHECK: return [[RET]]
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo7Struct1V5scaleyABSdFTO
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo10IAMStruct1V5scaleyABSdFTO
|
||||
// CHECK: bb0([[X:%.*]] : @trivial $Double, [[SELF:%.*]] : @trivial $Struct1):
|
||||
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1Scale
|
||||
// CHECK: [[RET:%.*]] = apply [[CFUNC]]([[SELF]], [[X]])
|
||||
// CHECK: return [[RET]]
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo7Struct1V12staticMethods5Int32VyFZTO
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo10IAMStruct1V12staticMethods5Int32VyFZTO
|
||||
// CHECK: bb0([[SELF:%.*]] : @trivial $@thin Struct1.Type):
|
||||
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1StaticMethod
|
||||
// CHECK: [[RET:%.*]] = apply [[CFUNC]]()
|
||||
// CHECK: return [[RET]]
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo7Struct1V13selfComesLast1xySd_tFTO
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo10IAMStruct1V13selfComesLast1xySd_tFTO
|
||||
// CHECK: bb0([[X:%.*]] : @trivial $Double, [[SELF:%.*]] : @trivial $Struct1):
|
||||
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1SelfComesLast
|
||||
// CHECK: apply [[CFUNC]]([[X]], [[SELF]])
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo7Struct1V14selfComesThird1a1b1xys5Int32V_SfSdtFTO
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo10IAMStruct1V14selfComesThird1a1b1xys5Int32V_SfSdtFTO
|
||||
// CHECK: bb0([[X:%.*]] : @trivial $Int32, [[Y:%.*]] : @trivial $Float, [[Z:%.*]] : @trivial $Double, [[SELF:%.*]] : @trivial $Struct1):
|
||||
// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1SelfComesThird
|
||||
// CHECK: apply [[CFUNC]]([[X]], [[Y]], [[SELF]], [[Z]])
|
||||
|
||||
@@ -54,7 +54,7 @@ public func useClass(d: Double, opts: SomeClass.Options) {
|
||||
}
|
||||
|
||||
extension SomeClass {
|
||||
// CHECK-LABEL: sil hidden @$SSo9SomeClassC16import_as_memberE6doubleABSd_tcfc
|
||||
// CHECK-LABEL: sil hidden @$SSo12IAMSomeClassC16import_as_memberE6doubleABSd_tcfc
|
||||
// CHECK: bb0([[DOUBLE:%[0-9]+]] : $Double
|
||||
// CHECK-NOT: value_metatype
|
||||
// CHECK: [[FNREF:%[0-9]+]] = function_ref @MakeIAMSomeClass
|
||||
|
||||
@@ -77,8 +77,8 @@ func single_protocol_composition(x: protocol<Foo>) {} // expected-warning {{'pro
|
||||
|
||||
// Clang-imported classes and protocols get mangled into a magic 'So' context
|
||||
// to make collisions into link errors. <rdar://problem/14221244>
|
||||
// CHECK-LABEL: sil hidden @$S8mangling28uses_objc_class_and_protocol1o1pySo8NSObjectC_So8NSAnsing_ptF
|
||||
func uses_objc_class_and_protocol(o: NSObject, p: NSAnsing) {}
|
||||
// CHECK-LABEL: sil hidden @$S8mangling28uses_objc_class_and_protocol1o1p2p2ySo8NSObjectC_So8NSAnsing_pSo14NSBetterAnsing_ptF
|
||||
func uses_objc_class_and_protocol(o: NSObject, p: NSAnsing, p2: BetterAnsing) {}
|
||||
|
||||
// Clang-imported structs get mangled using their Clang module name.
|
||||
// FIXME: Temporarily mangles everything into the virtual module __C__
|
||||
|
||||
@@ -15,7 +15,7 @@ func createErrorDomain(str: String) -> ErrorDomain {
|
||||
return ErrorDomain(rawValue: str)
|
||||
}
|
||||
|
||||
// CHECK-RAW-LABEL: sil shared [transparent] [serializable] @$SSo11ErrorDomainV8rawValueABSS_tcfC
|
||||
// CHECK-RAW-LABEL: sil shared [transparent] [serializable] @$SSo14SNTErrorDomaina8rawValueABSS_tcfC
|
||||
// CHECK-RAW: bb0([[STR:%[0-9]+]] : $String,
|
||||
// CHECK-RAW: [[SELF_BOX:%[0-9]+]] = alloc_box ${ var ErrorDomain }, var, name "self"
|
||||
// CHECK-RAW: [[MARKED_SELF_BOX:%[0-9]+]] = mark_uninitialized [rootself] [[SELF_BOX]]
|
||||
@@ -35,7 +35,7 @@ func getRawValue(ed: ErrorDomain) -> String {
|
||||
return ed.rawValue
|
||||
}
|
||||
|
||||
// CHECK-RAW-LABEL: sil shared [serializable] @$SSo11ErrorDomainV8rawValueSSvg
|
||||
// CHECK-RAW-LABEL: sil shared [serializable] @$SSo14SNTErrorDomaina8rawValueSSvg
|
||||
// CHECK-RAW: bb0([[SELF:%[0-9]+]] : $ErrorDomain):
|
||||
// CHECK-RAW: [[STORED_VALUE:%[0-9]+]] = struct_extract [[SELF]] : $ErrorDomain, #ErrorDomain._rawValue
|
||||
// CHECK-RAW: [[STORED_VALUE_COPY:%.*]] = copy_value [[STORED_VALUE]]
|
||||
@@ -46,21 +46,21 @@ func getRawValue(ed: ErrorDomain) -> String {
|
||||
// CHECK-RAW: return [[STRING_RESULT]]
|
||||
|
||||
class ObjCTest {
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype8ObjCTestC19optionalPassThroughySo11ErrorDomainVSgAGF : $@convention(method) (@owned Optional<ErrorDomain>, @guaranteed ObjCTest) -> @owned Optional<ErrorDomain> {
|
||||
// CHECK-RAW: sil hidden [thunk] @$S7newtype8ObjCTestC19optionalPassThroughySo11ErrorDomainVSgAGFTo : $@convention(objc_method) (Optional<ErrorDomain>, ObjCTest) -> Optional<ErrorDomain> {
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype8ObjCTestC19optionalPassThroughySo14SNTErrorDomainaSgAGF : $@convention(method) (@owned Optional<ErrorDomain>, @guaranteed ObjCTest) -> @owned Optional<ErrorDomain> {
|
||||
// CHECK-RAW: sil hidden [thunk] @$S7newtype8ObjCTestC19optionalPassThroughySo14SNTErrorDomainaSgAGFTo : $@convention(objc_method) (Optional<ErrorDomain>, ObjCTest) -> Optional<ErrorDomain> {
|
||||
@objc func optionalPassThrough(_ ed: ErrorDomain?) -> ErrorDomain? {
|
||||
return ed
|
||||
}
|
||||
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype8ObjCTestC18integerPassThroughySo5MyIntVAFF : $@convention(method) (MyInt, @guaranteed ObjCTest) -> MyInt {
|
||||
// CHECK-RAW: sil hidden [thunk] @$S7newtype8ObjCTestC18integerPassThroughySo5MyIntVAFFTo : $@convention(objc_method) (MyInt, ObjCTest) -> MyInt {
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype8ObjCTestC18integerPassThroughySo5MyIntaAFF : $@convention(method) (MyInt, @guaranteed ObjCTest) -> MyInt {
|
||||
// CHECK-RAW: sil hidden [thunk] @$S7newtype8ObjCTestC18integerPassThroughySo5MyIntaAFFTo : $@convention(objc_method) (MyInt, ObjCTest) -> MyInt {
|
||||
@objc func integerPassThrough(_ ed: MyInt) -> MyInt {
|
||||
return ed
|
||||
}
|
||||
}
|
||||
|
||||
// These use a bridging conversion with a specialization of a generic witness.
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype15bridgeToNewtypeSo8MyStringVyF
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype15bridgeToNewtypeSo8MyStringayF
|
||||
func bridgeToNewtype() -> MyString {
|
||||
// CHECK-RAW: [[STRING:%.*]] = apply
|
||||
// CHECK-RAW: [[TO_NS:%.*]] = function_ref @$SSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF
|
||||
@@ -73,7 +73,7 @@ func bridgeToNewtype() -> MyString {
|
||||
return "foo" as NSString as MyString
|
||||
}
|
||||
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype17bridgeFromNewtype6stringSSSo8MyStringV_tF
|
||||
// CHECK-RAW-LABEL: sil hidden @$S7newtype17bridgeFromNewtype6stringSSSo8MyStringa_tF
|
||||
func bridgeFromNewtype(string: MyString) -> String {
|
||||
// CHECK-RAW: [[FROM_MY:%.*]] = function_ref @$Ss20_SwiftNewtypeWrapperPss21_ObjectiveCBridgeable8RawValueRpzrlE09_bridgeToD1CAD_01_D5CTypeQZyF : $@convention(method) <τ_0_0 where τ_0_0 : _SwiftNewtypeWrapper, τ_0_0.RawValue : _ObjectiveCBridgeable> (@in_guaranteed τ_0_0) -> @owned τ_0_0.RawValue._ObjectiveCType
|
||||
// CHECK-RAW: [[NS:%.*]] = apply [[FROM_MY]]<MyString, String>(
|
||||
|
||||
@@ -754,5 +754,5 @@ func bridgeOptionalFunctionToAnyObject(fn: (() -> ())?) -> AnyObject {
|
||||
|
||||
// CHECK-LABEL: sil_witness_table shared [serialized] GenericOption: Hashable module objc_generics {
|
||||
// CHECK-NEXT: base_protocol Equatable: GenericOption: Equatable module objc_generics
|
||||
// CHECK-NEXT: method #Hashable.hashValue!getter.1: {{.*}} : @$SSo13GenericOptionVs8Hashable13objc_genericssACP9hashValueSivgTW
|
||||
// CHECK-NEXT: method #Hashable.hashValue!getter.1: {{.*}} : @$SSo13GenericOptionas8Hashable13objc_genericssACP9hashValueSivgTW
|
||||
// CHECK-NEXT: }
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
import gizmo
|
||||
|
||||
|
||||
// CHECK-DAG: sil shared [serializable] @$SSo16NSRuncingOptionsO{{[_0-9a-zA-Z]*}}fC
|
||||
// CHECK-DAG: sil shared [serializable] @$SSo16NSRuncingOptionsO8rawValueSivg
|
||||
// CHECK-DAG: sil shared [serializable] @$SSo16NSRuncingOptionsO9hashValueSivg
|
||||
// CHECK-DAG: sil shared [serializable] @$SSo16NSRuncingOptionsV{{[_0-9a-zA-Z]*}}fC
|
||||
// CHECK-DAG: sil shared [serializable] @$SSo16NSRuncingOptionsV8rawValueSivg
|
||||
// CHECK-DAG: sil shared [serializable] @$SSo16NSRuncingOptionsV9hashValueSivg
|
||||
|
||||
// Non-payload enum ctors don't need to be instantiated at all.
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsO5MinceAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsO12QuinceSlicedAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsO15QuinceJuliennedAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsO11QuinceDicedAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsV5MinceAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsV12QuinceSlicedAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsV15QuinceJuliennedAbBmF
|
||||
// NEGATIVE-NOT: sil shared [transparent] @$SSo16NSRuncingOptionsV11QuinceDicedAbBmF
|
||||
|
||||
var runcing: NSRuncingOptions = .mince
|
||||
|
||||
@@ -45,7 +45,7 @@ _ = NSFungingMask.toTheMax
|
||||
// CHECK-DAG: sil_witness_table shared [serialized] NSRuncingOptions: Hashable module gizmo
|
||||
// CHECK-DAG: sil_witness_table shared [serialized] NSFungingMask: RawRepresentable module gizmo
|
||||
|
||||
// CHECK-DAG: sil shared [transparent] [serialized] [thunk] @$SSo16NSRuncingOptionsOs16RawRepresentable5gizmosACP{{[_0-9a-zA-Z]*}}fCTW
|
||||
// CHECK-DAG: sil shared [transparent] [serialized] [thunk] @$SSo16NSRuncingOptionsVs16RawRepresentable5gizmosACP{{[_0-9a-zA-Z]*}}fCTW
|
||||
|
||||
// Extension conformances get linkage according to the protocol's accessibility, as normal.
|
||||
// CHECK-DAG: sil_witness_table hidden NSRuncingOptions: Bub module objc_enum
|
||||
|
||||
@@ -66,12 +66,12 @@ extension Hive {
|
||||
}
|
||||
|
||||
extension SomeClass {
|
||||
// CHECK-LABEL: sil hidden @$SSo9SomeClassC17objc_factory_initE6doubleABSd_tcfc : $@convention(method) (Double, @owned SomeClass) -> @owned SomeClass {
|
||||
// CHECK-LABEL: sil hidden @$SSo12IAMSomeClassC17objc_factory_initE6doubleABSd_tcfc : $@convention(method) (Double, @owned SomeClass) -> @owned SomeClass {
|
||||
// CHECK: bb0([[DOUBLE:%.*]] : @trivial $Double,
|
||||
// CHECK-NOT: value_metatype
|
||||
// CHECK: [[FNREF:%[0-9]+]] = function_ref @MakeIAMSomeClass
|
||||
// CHECK: apply [[FNREF]]([[DOUBLE]])
|
||||
// CHECK: } // end sil function '$SSo9SomeClassC17objc_factory_initE6doubleABSd_tcfc'
|
||||
// CHECK: } // end sil function '$SSo12IAMSomeClassC17objc_factory_initE6doubleABSd_tcfc'
|
||||
convenience init(double: Double) {
|
||||
self.init(value: double)
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func configureWithoutOptions() {
|
||||
// foreign to native thunk for init(options:), uses GenericOption : Hashable
|
||||
// conformance
|
||||
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo12GenericClassC7optionsSQyAByxGGs10DictionaryVySo0A6OptionVypGSg_tcfcTO : $@convention(method) <T where T : AnyObject> (@owned Optional<Dictionary<GenericOption, Any>>, @owned GenericClass<T>) -> @owned Optional<GenericClass<T>>
|
||||
// CHECK-LABEL: sil shared [serializable] [thunk] @$SSo12GenericClassC7optionsSQyAByxGGs10DictionaryVySo0A6OptionaypGSg_tcfcTO : $@convention(method) <T where T : AnyObject> (@owned Optional<Dictionary<GenericOption, Any>>, @owned GenericClass<T>) -> @owned Optional<GenericClass<T>>
|
||||
// CHECK: [[FN:%.*]] = function_ref @$Ss10DictionaryV10FoundationE19_bridgeToObjectiveCSo12NSDictionaryCyF : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned NSDictionary
|
||||
// CHECK: apply [[FN]]<GenericOption, Any>({{.*}}) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned NSDictionary
|
||||
// CHECK: return
|
||||
@@ -141,5 +141,5 @@ func configureWithoutOptions() {
|
||||
// Make sure we emitted the witness table for the above conformance
|
||||
|
||||
// CHECK-LABEL: sil_witness_table shared [serialized] GenericOption: Hashable module objc_generics {
|
||||
// CHECK: method #Hashable.hashValue!getter.1: {{.*}}: @$SSo13GenericOptionVs8Hashable13objc_genericssACP9hashValueSivgTW
|
||||
// CHECK: method #Hashable.hashValue!getter.1: {{.*}}: @$SSo13GenericOptionas8Hashable13objc_genericssACP9hashValueSivgTW
|
||||
// CHECK: }
|
||||
|
||||
@@ -779,22 +779,22 @@ print("Swift to NS sets: End")
|
||||
|
||||
// Check optimizations of casts from String to CFString
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding29testForcedCastSwiftToCFStringSo0I0CyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding29testForcedCastSwiftToCFStringSo0I3RefayF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSString to $CFString
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding29testForcedCastSwiftToCFStringSo0I0CyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding29testForcedCastSwiftToCFStringSo0I3RefayF
|
||||
@inline(never)
|
||||
public func testForcedCastSwiftToCFString() -> CFString {
|
||||
let o: CFString = forcedCast(swiftString)
|
||||
return o
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding27testCondCastSwiftToCFStringSo0I0CSgyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding27testCondCastSwiftToCFStringSo0I3RefaSgyF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSString to $CFString
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding27testCondCastSwiftToCFStringSo0I0CSgyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding27testCondCastSwiftToCFStringSo0I3RefaSgyF
|
||||
@inline(never)
|
||||
public func testCondCastSwiftToCFString() -> CFString? {
|
||||
let o: CFString? = condCast(swiftString)
|
||||
@@ -803,22 +803,22 @@ public func testCondCastSwiftToCFString() -> CFString? {
|
||||
|
||||
// Check optimizations of casts from Int to CFNumber
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding32testForcedCastSwiftIntToCFNumberSo0J0CyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding32testForcedCastSwiftIntToCFNumberSo0J3RefayF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSNumber to $CFNumber
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding32testForcedCastSwiftIntToCFNumberSo0J0CyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding32testForcedCastSwiftIntToCFNumberSo0J3RefayF
|
||||
@inline(never)
|
||||
public func testForcedCastSwiftIntToCFNumber() -> CFNumber {
|
||||
let o: CFNumber = forcedCast(swiftIntNumber)
|
||||
return o
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding30testCondCastSwiftIntToCFNumberSo0J0CSgyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding30testCondCastSwiftIntToCFNumberSo0J3RefaSgyF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSNumber to $CFNumber
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding30testCondCastSwiftIntToCFNumberSo0J0CSgyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding30testCondCastSwiftIntToCFNumberSo0J3RefaSgyF
|
||||
@inline(never)
|
||||
public func testCondCastSwiftIntToCFNumber() -> CFNumber? {
|
||||
let o: CFNumber? = condCast(swiftIntNumber)
|
||||
@@ -827,22 +827,22 @@ public func testCondCastSwiftIntToCFNumber() -> CFNumber? {
|
||||
|
||||
// Check optimization of casts from Swift Array to CFArray
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding31testForcedCastSwiftToCFArrayIntSo0I0CyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding31testForcedCastSwiftToCFArrayIntSo0I3RefayF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSArray to $CFArray
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding31testForcedCastSwiftToCFArrayIntSo0I0CyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding31testForcedCastSwiftToCFArrayIntSo0I3RefayF
|
||||
@inline(never)
|
||||
public func testForcedCastSwiftToCFArrayInt() -> CFArray {
|
||||
let arr: CFArray = forcedCast(arrInt)
|
||||
return arr
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding29testCondCastSwiftToCFArrayIntSo0I0CSgyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding29testCondCastSwiftToCFArrayIntSo0I3RefaSgyF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSArray to $CFArray
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding29testCondCastSwiftToCFArrayIntSo0I0CSgyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding29testCondCastSwiftToCFArrayIntSo0I3RefaSgyF
|
||||
@inline(never)
|
||||
public func testCondCastSwiftToCFArrayInt() -> CFArray? {
|
||||
let arrOpt: CFArray? = condCast(arrInt)
|
||||
@@ -851,22 +851,22 @@ public func testCondCastSwiftToCFArrayInt() -> CFArray? {
|
||||
|
||||
// Check optimization of casts from Swift Dict to CFDictionary
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding30testForcedCastSwiftToCFDictIntSo12CFDictionaryCyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding30testForcedCastSwiftToCFDictIntSo15CFDictionaryRefayF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSDictionary to $CFDictionary
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding30testForcedCastSwiftToCFDictIntSo12CFDictionaryCyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding30testForcedCastSwiftToCFDictIntSo15CFDictionaryRefayF
|
||||
@inline(never)
|
||||
public func testForcedCastSwiftToCFDictInt() -> CFDictionary {
|
||||
let dict: CFDictionary = forcedCast(dictInt)
|
||||
return dict
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding28testCondCastSwiftToCFDictIntSo12CFDictionaryCSgyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding28testCondCastSwiftToCFDictIntSo15CFDictionaryRefaSgyF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSDictionary to $CFDictionary
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding28testCondCastSwiftToCFDictIntSo12CFDictionaryCSgyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding28testCondCastSwiftToCFDictIntSo15CFDictionaryRefaSgyF
|
||||
@inline(never)
|
||||
public func testCondCastSwiftToCFDictInt() -> CFDictionary? {
|
||||
let dictOpt: CFDictionary? = condCast(dictInt)
|
||||
@@ -875,22 +875,22 @@ public func testCondCastSwiftToCFDictInt() -> CFDictionary? {
|
||||
|
||||
// Check optimization of casts from Swift Set to CFSet
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding29testForcedCastSwiftToCFSetIntSo0I0CyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding29testForcedCastSwiftToCFSetIntSo0I3RefayF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSSet to $CFSet
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding29testForcedCastSwiftToCFSetIntSo0I0CyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding29testForcedCastSwiftToCFSetIntSo0I3RefayF
|
||||
@inline(never)
|
||||
public func testForcedCastSwiftToCFSetInt() -> CFSet {
|
||||
let set: CFSet = forcedCast(setInt)
|
||||
return set
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding27testCondCastSwiftToCFSetIntSo0I0CSgyF
|
||||
// CHECK-LABEL: sil [noinline] @$S21bridged_casts_folding27testCondCastSwiftToCFSetIntSo0I3RefaSgyF
|
||||
// CHECK-NOT: unconditional_checked
|
||||
// CHECK: function_ref @{{.*}}_bridgeToObjectiveC
|
||||
// CHECK: unchecked_ref_cast{{.*}}: $NSSet to $CFSet
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding27testCondCastSwiftToCFSetIntSo0I0CSgyF
|
||||
// CHECK: end{{.*}}$S21bridged_casts_folding27testCondCastSwiftToCFSetIntSo0I3RefaSgyF
|
||||
@inline(never)
|
||||
public func testCondCastSwiftToCFSetInt() -> CFSet? {
|
||||
let setOpt: CFSet? = condCast(setInt)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import Foundation
|
||||
import UsesImportedEnums
|
||||
|
||||
// CHECK-LABEL: sil hidden @$S4main4test1eSbSo13NSRuncingModeO_tF
|
||||
// CHECK-LABEL: sil hidden @$S4main4test1eSbSo13NSRuncingModeV_tF
|
||||
func test(e: NSRuncingMode) -> Bool {
|
||||
// CHECK-NOT: return
|
||||
// CHECK: $Ss2eeoiySbx_xts16RawRepresentableRzs9Equatable0B5ValueRpzlF
|
||||
|
||||
@@ -28,5 +28,5 @@
|
||||
|
||||
// CHECK: key.kind: source.lang.swift.decl.var.static,
|
||||
// CHECK-NEXT: key.name: "errFirst",
|
||||
// CHECK-NEXT: key.usr: "s:SC7MyErrorV8errFirstAB4CodeOvpZ",
|
||||
// CHECK-NEXT: key.usr: "s:SC7MyErrorV8errFirstSo0aB4CodeVvpZ",
|
||||
// CHECK-NEXT: This is first error.
|
||||
|
||||
@@ -63,7 +63,7 @@ print("ObjC quick look objects:")
|
||||
// CHECK-LABEL: ObjC enums:
|
||||
print("ObjC enums:")
|
||||
|
||||
// CHECK-NEXT: We cannot reflect ComparisonResult yet
|
||||
// CHECK-NEXT: We cannot reflect NSComparisonResult yet
|
||||
print("We cannot reflect \(ComparisonResult.orderedAscending) yet")
|
||||
|
||||
// Don't crash when introspecting framework types such as NSURL.
|
||||
|
||||
@@ -361,7 +361,7 @@ Runtime.test("Generic class ObjC runtime names") {
|
||||
expectEqual("_TtGC1a12GenericClassMPS_9ProtocolAS_9ProtocolB__",
|
||||
NSStringFromClass(GenericClass<(ProtocolB & ProtocolA).Protocol>.self))
|
||||
|
||||
expectEqual("_TtGC1a12GenericClassCSo7CFArray_",
|
||||
expectEqual("_TtGC1a12GenericClassaSo10CFArrayRef_",
|
||||
NSStringFromClass(GenericClass<CFArray>.self))
|
||||
expectEqual("_TtGC1a12GenericClassVSo7Decimal_",
|
||||
NSStringFromClass(GenericClass<Decimal>.self))
|
||||
@@ -761,8 +761,8 @@ Reflection.test("Unmanaged/not-nil") {
|
||||
dump(optionalURL, to: &output)
|
||||
|
||||
let expected =
|
||||
"▿ Optional(Swift.Unmanaged<__C.CFURL>(_value: http://llvm.org/))\n" +
|
||||
" ▿ some: Swift.Unmanaged<__C.CFURL>\n" +
|
||||
"▿ Optional(Swift.Unmanaged<__C.CFURLRef>(_value: http://llvm.org/))\n" +
|
||||
" ▿ some: Swift.Unmanaged<__C.CFURLRef>\n" +
|
||||
" - _value: http://llvm.org/ #0\n" +
|
||||
" - super: NSObject\n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user