diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index d4cb352d658dd..de058961d2909 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -378,7 +378,7 @@ macro(configure_sdk_unix name architectures) message(FATAL_ERROR "unknown arch for ${prefix}: ${arch}") endif() elseif("${prefix}" STREQUAL "FREEBSD") - if(NOT arch STREQUAL x86_64) + if(NOT arch MATCHES "(arm64|x86_64)") message(FATAL_ERROR "unsupported arch for FreeBSD: ${arch}") endif() @@ -389,7 +389,7 @@ macro(configure_sdk_unix name architectures) string(REGEX REPLACE "[-].*" "" freebsd_system_version ${CMAKE_SYSTEM_VERSION}) message(STATUS "FreeBSD Version: ${freebsd_system_version}") - set(SWIFT_SDK_FREEBSD_ARCH_x86_64_TRIPLE "x86_64-unknown-freebsd${freebsd_system_version}") + set(SWIFT_SDK_FREEBSD_ARCH_${arch}_TRIPLE "${arch}-unknown-freebsd${freebsd_system_version}") elseif("${prefix}" STREQUAL "OPENBSD") if(NOT arch STREQUAL amd64) message(FATAL_ERROR "unsupported arch for OpenBSD: ${arch}") diff --git a/include/swift/AST/PrintOptions.h b/include/swift/AST/PrintOptions.h index d9ef12a86c133..722d9cd459135 100644 --- a/include/swift/AST/PrintOptions.h +++ b/include/swift/AST/PrintOptions.h @@ -553,6 +553,12 @@ struct PrintOptions { /// Whether to always desugar optional types from `base_type?` to `Optional` bool AlwaysDesugarOptionalTypes = false; + /// Whether to always print explicit `Pack{...}` around pack + /// types. + /// + /// This is set to \c false for diagnostic arguments. + bool PrintExplicitPackTypes = true; + /// \see ShouldQualifyNestedDeclarations enum class QualifyNestedDeclarations { Never, @@ -606,6 +612,7 @@ struct PrintOptions { /// The print options used for formatting diagnostic arguments. static PrintOptions forDiagnosticArguments() { PrintOptions result; + result.PrintExplicitPackTypes = false; return result; } diff --git a/include/swift/Runtime/Enum.h b/include/swift/Runtime/Enum.h index 21d8b4901b369..4eaa6c8ac2032 100644 --- a/include/swift/Runtime/Enum.h +++ b/include/swift/Runtime/Enum.h @@ -45,6 +45,11 @@ void swift_initEnumMetadataSingleCase(EnumMetadata *enumType, EnumLayoutFlags flags, const TypeLayout *payload); +SWIFT_RUNTIME_EXPORT +void swift_initEnumMetadataSingleCaseWithLayoutString( + EnumMetadata *self, EnumLayoutFlags layoutFlags, + const Metadata *payloadType); + /// Initialize the type metadata for a single-payload enum type. /// /// \param enumType - pointer to the instantiated but uninitialized metadata diff --git a/include/swift/Runtime/RuntimeFunctions.def b/include/swift/Runtime/RuntimeFunctions.def index 8ab6e20a1d147..0d88cd1258647 100644 --- a/include/swift/Runtime/RuntimeFunctions.def +++ b/include/swift/Runtime/RuntimeFunctions.def @@ -1300,6 +1300,17 @@ FUNCTION(InitEnumMetadataSingleCase, ATTRS(NoUnwind, WillReturn), EFFECT(MetaData)) +// void swift_initEnumMetadataSingleCaseWithLayoutString(Metadata *enumType, +// EnumLayoutFlags flags, +// Metadata *payload); +FUNCTION(InitEnumMetadataSingleCaseWithLayoutString, + swift_initEnumMetadataSingleCaseWithLayoutString, + C_CC, AlwaysAvailable, + RETURNS(VoidTy), + ARGS(TypeMetadataPtrTy, SizeTy, TypeMetadataPtrTy), + ATTRS(NoUnwind, WillReturn), + EFFECT(MetaData)) + // void swift_initEnumMetadataSinglePayload(Metadata *enumType, // EnumLayoutFlags flags, // TypeLayout *payload, diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index bff08aa14dd7c..47f1720a9be45 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -6051,7 +6051,8 @@ class TypePrinter : public TypeVisitor { } void visitPackType(PackType *T) { - Printer << "Pack{"; + if (Options.PrintExplicitPackTypes) + Printer << "Pack{"; auto Fields = T->getElementTypes(); for (unsigned i = 0, e = Fields.size(); i != e; ++i) { @@ -6060,7 +6061,9 @@ class TypePrinter : public TypeVisitor { Type EltType = Fields[i]; visit(EltType); } - Printer << "}"; + + if (Options.PrintExplicitPackTypes) + Printer << "}"; } void visitSILPackType(SILPackType *T) { diff --git a/lib/IRGen/GenEnum.cpp b/lib/IRGen/GenEnum.cpp index 42542c7e3c240..18f1f7f28f4ad 100644 --- a/lib/IRGen/GenEnum.cpp +++ b/lib/IRGen/GenEnum.cpp @@ -663,13 +663,42 @@ namespace { metadata); } - void initializeMetadataWithLayoutString(IRGenFunction &IGF, - llvm::Value *metadata, - bool isVWTMutable, - SILType T, - MetadataDependencyCollector *collector) const override { - // Not yet supported on this type, so forward to regular method - initializeMetadata(IGF, metadata, isVWTMutable, T, collector); + void initializeMetadataWithLayoutString( + IRGenFunction &IGF, llvm::Value *metadata, bool isVWTMutable, SILType T, + MetadataDependencyCollector *collector) const override { + if (TIK >= Fixed) + return; + + assert(ElementsWithPayload.size() == 1 && + "empty singleton enum should not be dynamic!"); + + auto payloadTy = + T.getEnumElementType(ElementsWithPayload[0].decl, IGM.getSILModule(), + IGM.getMaximalTypeExpansionContext()); + + auto request = DynamicMetadataRequest::getNonBlocking( + MetadataState::LayoutComplete, collector); + auto payloadMetadata = + IGF.emitTypeMetadataRefForLayout(payloadTy, request); + + auto flags = emitEnumLayoutFlags(IGF.IGM, isVWTMutable); + IGF.Builder.CreateCall( + IGF.IGM + .getInitEnumMetadataSingleCaseWithLayoutStringFunctionPointer(), + {metadata, flags, payloadMetadata}); + + // Pre swift-5.1 runtimes were missing the initialization of the + // the extraInhabitantCount field. Do it here instead. + auto payloadLayout = emitTypeLayoutRef(IGF, payloadTy, collector); + auto payloadRef = IGF.Builder.CreateBitOrPointerCast( + payloadLayout, IGF.IGM.TypeLayoutTy->getPointerTo()); + auto payloadExtraInhabitantCount = + IGF.Builder.CreateLoad(IGF.Builder.CreateStructGEP( + Address(payloadRef, IGF.IGM.TypeLayoutTy, Alignment(1)), 3, + Size(IGF.IGM.DataLayout.getTypeAllocSize(IGF.IGM.SizeTy) * 2 + + IGF.IGM.DataLayout.getTypeAllocSize(IGF.IGM.Int32Ty)))); + emitStoreOfExtraInhabitantCount(IGF, payloadExtraInhabitantCount, + metadata); } bool mayHaveExtraInhabitants(IRGenModule &IGM) const override { @@ -973,11 +1002,9 @@ namespace { // witness table initialization. } - void initializeMetadataWithLayoutString(IRGenFunction &IGF, - llvm::Value *metadata, - bool isVWTMutable, - SILType T, - MetadataDependencyCollector *collector) const override { + void initializeMetadataWithLayoutString( + IRGenFunction &IGF, llvm::Value *metadata, bool isVWTMutable, SILType T, + MetadataDependencyCollector *collector) const override { // No-payload enums are always fixed-size so never need dynamic value // witness table initialization. } @@ -3207,11 +3234,9 @@ namespace { {metadata, flags, payloadLayout, emptyCasesVal}); } - void initializeMetadataWithLayoutString(IRGenFunction &IGF, - llvm::Value *metadata, - bool isVWTMutable, - SILType T, - MetadataDependencyCollector *collector) const override { + void initializeMetadataWithLayoutString( + IRGenFunction &IGF, llvm::Value *metadata, bool isVWTMutable, SILType T, + MetadataDependencyCollector *collector) const override { // Not yet supported on this type, so forward to regular method initializeMetadata(IGF, metadata, isVWTMutable, T, collector); } @@ -5335,11 +5360,9 @@ namespace { {metadata, flags, numPayloadsVal, payloadLayoutArray}); } - void initializeMetadataWithLayoutString(IRGenFunction &IGF, - llvm::Value *metadata, - bool isVWTMutable, - SILType T, - MetadataDependencyCollector *collector) const override { + void initializeMetadataWithLayoutString( + IRGenFunction &IGF, llvm::Value *metadata, bool isVWTMutable, SILType T, + MetadataDependencyCollector *collector) const override { // Fixed-size enums don't need dynamic metadata initialization. if (TIK >= Fixed) return; @@ -6035,11 +6058,9 @@ namespace { llvm_unreachable("resilient enums cannot be defined"); } - void initializeMetadataWithLayoutString(IRGenFunction &IGF, - llvm::Value *metadata, - bool isVWTMutable, - SILType T, - MetadataDependencyCollector *collector) const override { + void initializeMetadataWithLayoutString( + IRGenFunction &IGF, llvm::Value *metadata, bool isVWTMutable, SILType T, + MetadataDependencyCollector *collector) const override { llvm_unreachable("resilient enums cannot be defined"); } diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp index c46a4dac25f22..3a67800eb009e 100644 --- a/lib/IRGen/GenMeta.cpp +++ b/lib/IRGen/GenMeta.cpp @@ -5737,14 +5737,17 @@ namespace { } auto &strategy = getEnumImplStrategy(IGM, getLoweredType()); + bool isSupportedCase = strategy.getElementsWithPayload().size() > 1 || + (strategy.getElementsWithPayload().size() == 1 && + strategy.getElementsWithNoPayload().empty()); return !!getLayoutString() || (IGM.Context.LangOpts.hasFeature( - Feature::LayoutStringValueWitnessesInstantiation) && + Feature::LayoutStringValueWitnessesInstantiation) && IGM.getOptions().EnableLayoutStringValueWitnessesInstantiation && - (HasDependentVWT || HasDependentMetadata) && - !isa(IGM.getTypeInfo(getLoweredType())) && - strategy.getElementsWithPayload().size() > 1); + (HasDependentVWT || HasDependentMetadata) && + !isa(IGM.getTypeInfo(getLoweredType())) && + isSupportedCase); } llvm::Constant *emitNominalTypeDescriptor() { diff --git a/lib/IRGen/GenValueWitness.cpp b/lib/IRGen/GenValueWitness.cpp index 886297dd948a3..fb9693e6857d2 100644 --- a/lib/IRGen/GenValueWitness.cpp +++ b/lib/IRGen/GenValueWitness.cpp @@ -892,7 +892,7 @@ bool isRuntimeInstatiatedLayoutString(IRGenModule &IGM, Feature::LayoutStringValueWitnessesInstantiation) && IGM.getOptions().EnableLayoutStringValueWitnessesInstantiation) { if (auto *enumEntry = typeLayoutEntry->getAsEnum()) { - return enumEntry->isMultiPayloadEnum(); + return enumEntry->isMultiPayloadEnum() || enumEntry->isSingleton(); } return (typeLayoutEntry->isAlignedGroup() && !typeLayoutEntry->isFixedSize(IGM)); diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index ef4d285a12f9f..71b7ca6015c51 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -120,14 +120,6 @@ Type FailureDiagnostic::resolveType(Type rawType, bool reconstituteSugar, return env->mapElementTypeIntoPackContext(type); } - if (auto *packType = type->getAs()) { - if (packType->getNumElements() == 1) { - auto eltType = resolveType(packType->getElementType(0)); - if (auto expansion = eltType->getAs()) - return expansion->getPatternType(); - } - } - return type->isPlaceholder() ? Type(type->getASTContext().TheUnresolvedType) : type; }); diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp index 82be86ccf35bf..862203b191911 100644 --- a/lib/Sema/TypeCheckGeneric.cpp +++ b/lib/Sema/TypeCheckGeneric.cpp @@ -838,6 +838,7 @@ static std::string gatherGenericParamBindingsText( SmallString<128> result; llvm::raw_svector_ostream OS(result); + auto options = PrintOptions::forDiagnosticArguments(); for (auto gp : genericParams) { auto canonGP = gp->getCanonicalType()->castTo(); @@ -859,19 +860,7 @@ static std::string gatherGenericParamBindingsText( if (!type) return ""; - if (auto *packType = type->getAs()) { - bool first = true; - for (auto eltType : packType->getElementTypes()) { - if (first) - first = false; - else - OS << ", "; - - OS << eltType; - } - } else { - OS << type.getString(); - } + type->print(OS, options); } OS << "]"; diff --git a/stdlib/public/runtime/Enum.cpp b/stdlib/public/runtime/Enum.cpp index 13c00ed9dcc97..38c4b316f19ab 100644 --- a/stdlib/public/runtime/Enum.cpp +++ b/stdlib/public/runtime/Enum.cpp @@ -65,6 +65,61 @@ swift::swift_initEnumMetadataSingleCase(EnumMetadata *self, vwtable->publishLayout(layout); } +void swift::swift_initEnumMetadataSingleCaseWithLayoutString( + EnumMetadata *self, EnumLayoutFlags layoutFlags, + const Metadata *payloadType) { + assert(self->hasLayoutString()); + + auto payloadLayout = payloadType->getTypeLayout(); + auto vwtable = getMutableVWTableForInit(self, layoutFlags); + + TypeLayout layout; + layout.size = payloadLayout->size; + layout.stride = payloadLayout->stride; + layout.flags = payloadLayout->flags.withEnumWitnesses(true); + layout.extraInhabitantCount = payloadLayout->getNumExtraInhabitants(); + + auto refCountBytes = _swift_refCountBytesForMetatype(payloadType); + const size_t fixedLayoutStringSize = + layoutStringHeaderSize + sizeof(uint64_t) * 2; + + uint8_t *layoutStr = + (uint8_t *)MetadataAllocator(LayoutStringTag) + .Allocate(fixedLayoutStringSize + refCountBytes, alignof(uint8_t)); + + size_t layoutStrOffset = sizeof(uint64_t); + writeBytes(layoutStr, layoutStrOffset, refCountBytes); + size_t fullOffset = 0; + size_t previousFieldOffset = 0; + LayoutStringFlags flags = LayoutStringFlags::Empty; + + _swift_addRefCountStringForMetatype(layoutStr, layoutStrOffset, flags, + payloadType, fullOffset, + previousFieldOffset); + + writeBytes(layoutStr, layoutStrOffset, (uint64_t)previousFieldOffset); + writeBytes(layoutStr, layoutStrOffset, (uint64_t)0); + + // we mask out HasRelativePointers, because at this point they have all been + // resolved to metadata pointers + layoutStrOffset = 0; + writeBytes(layoutStr, layoutStrOffset, + ((uint64_t)flags) & + ~((uint64_t)LayoutStringFlags::HasRelativePointers)); + + vwtable->destroy = swift_generic_destroy; + vwtable->initializeWithCopy = swift_generic_initWithCopy; + vwtable->initializeWithTake = swift_generic_initWithTake; + vwtable->assignWithCopy = swift_generic_assignWithCopy; + vwtable->assignWithTake = swift_generic_assignWithTake; + + installCommonValueWitnesses(layout, vwtable); + + self->setLayoutString(layoutStr); + + vwtable->publishLayout(layout); +} + void swift::swift_initEnumMetadataSinglePayload(EnumMetadata *self, EnumLayoutFlags layoutFlags, @@ -221,6 +276,8 @@ void swift::swift_initEnumMetadataMultiPayloadWithLayoutString( EnumLayoutFlags layoutFlags, unsigned numPayloads, const Metadata * const *payloadLayouts) { + assert(enumType->hasLayoutString()); + // Accumulate the layout requirements of the payloads. size_t payloadSize = 0, alignMask = 0; bool isPOD = true, isBT = true; diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp index 5e5c9590aca2d..b2fb2d93368c7 100644 --- a/stdlib/public/runtime/Metadata.cpp +++ b/stdlib/public/runtime/Metadata.cpp @@ -2750,8 +2750,8 @@ void swift::swift_initStructMetadataWithLayoutString( previousFieldOffset); } - writeBytes(layoutStr, layoutStrOffset, previousFieldOffset); - writeBytes(layoutStr, layoutStrOffset, 0); + writeBytes(layoutStr, layoutStrOffset, (uint64_t)previousFieldOffset); + writeBytes(layoutStr, layoutStrOffset, (uint64_t)0); // we mask out HasRelativePointers, because at this point they have all been // resolved to metadata pointers diff --git a/test/Constraints/pack-expansion-expressions.swift b/test/Constraints/pack-expansion-expressions.swift index a718ed2944acd..8c09b8e167ca5 100644 --- a/test/Constraints/pack-expansion-expressions.swift +++ b/test/Constraints/pack-expansion-expressions.swift @@ -138,7 +138,7 @@ func tupleExpansion( _ = zip(repeat each tuple1, with: repeat each tuple1.element) // legacy syntax _ = zip(repeat each tuple1, with: repeat each tuple2) - // expected-error@-1 {{global function 'zip(_:with:)' requires the type packs 'each T' and 'each U' have the same shape}} + // expected-error@-1 {{global function 'zip(_:with:)' requires the type packs 'repeat each T' and 'repeat each U' have the same shape}} _ = forward(repeat each tuple3) } diff --git a/test/Constraints/pack_expansion_types.swift b/test/Constraints/pack_expansion_types.swift index 1ac71c1421acb..92472e78cda16 100644 --- a/test/Constraints/pack_expansion_types.swift +++ b/test/Constraints/pack_expansion_types.swift @@ -240,9 +240,9 @@ func patternInstantiationConcreteValid() { func patternInstantiationConcreteInvalid() { let _: Set = patternInstantiationTupleTest1() - // expected-error@-1 {{cannot convert value of type '(repeat Array)' to specified type 'Set'}} + // expected-error@-1 {{cannot convert value of type '(repeat Array<_>)' to specified type 'Set'}} - let _: (Array, Set) = patternInstantiationTupleTest1() // expected-error {{'(repeat Array)' is not convertible to '(Array, Set)', tuples have a different number of elements}} + let _: (Array, Set) = patternInstantiationTupleTest1() // expected-error {{'(repeat Array)' is not convertible to '(Array, Set)', tuples have a different number of elements}} } func patternInstantiationGenericValid(t: repeat each T, u: repeat each U) @@ -272,7 +272,7 @@ func patternInstantiationGenericInvalid(t: repeat each T) { let _: (repeat Set) = patternInstantiationTupleTest1() // expected-error {{cannot convert value of type '(repeat Array)' to specified type '(repeat Set)}} // expected-error@-1 {{generic parameter 'each T' could not be inferred}} - let _: (repeat Array, Set) = patternInstantiationTupleTest1() // expected-error {{'(repeat Array)' is not convertible to '(repeat Array, Set)', tuples have a different number of elements}} + let _: (repeat Array, Set) = patternInstantiationTupleTest1() // expected-error {{'(repeat Array)' is not convertible to '(repeat Array, Set)', tuples have a different number of elements}} } // rdar://107996926 - Vanishing metatype of tuple not supported diff --git a/test/Constraints/variadic_generic_constraints.swift b/test/Constraints/variadic_generic_constraints.swift index 1748a4d9058b1..ce3d26786365c 100644 --- a/test/Constraints/variadic_generic_constraints.swift +++ b/test/Constraints/variadic_generic_constraints.swift @@ -65,7 +65,7 @@ let _ = zip(t: 1, u: "hi") // ok let _ = zip(t: 1, 2, u: "hi", "hello") // ok let _ = zip(t: 1, 2, 3, u: "hi", "hello", "greetings") // ok let _ = zip(t: 1, u: "hi", "hello", "greetings") // expected-error {{extra arguments at positions #3, #4 in call}} -// expected-error@-1 {{global function 'zip(t:u:)' requires the type packs 'Pack{Int}' and 'Pack{String, String, String}' have the same shape}} +// expected-error@-1 {{global function 'zip(t:u:)' requires the type packs 'Int' and 'String, String, String' have the same shape}} func goodCallToZip(t: repeat each T, u: repeat each U) where (repeat (each T, each U)): Any { _ = zip(t: repeat each t, u: repeat each u) @@ -73,5 +73,5 @@ func goodCallToZip(t: repeat each T, u: repeat each U) where (re func badCallToZip(t: repeat each T, u: repeat each U) { _ = zip(t: repeat each t, u: repeat each u) - // expected-error@-1 {{global function 'zip(t:u:)' requires the type packs 'each T' and 'each U' have the same shape}} + // expected-error@-1 {{global function 'zip(t:u:)' requires the type packs 'repeat each T' and 'repeat each U' have the same shape}} } diff --git a/test/Constraints/variadic_generic_types.swift b/test/Constraints/variadic_generic_types.swift index 2812198e7c0c2..8ff200b253297 100644 --- a/test/Constraints/variadic_generic_types.swift +++ b/test/Constraints/variadic_generic_types.swift @@ -22,3 +22,10 @@ func g(_: repeat each T) { // expected-error@-1 {{pack expansion 'Int' must contain at least one pack reference}} // expected-error@-2 {{'each' cannot be applied to non-pack type 'Int'}}{{15-19=}} } + +struct MissingMemberError { + init() { + self.doesNotExist = 1 + // expected-error@-1 {{value of type 'MissingMemberError' has no member 'doesNotExist'}} + } +} diff --git a/test/Generics/variadic_generic_requirements.swift b/test/Generics/variadic_generic_requirements.swift index dbf18ea6da67b..6be7b41be8fd3 100644 --- a/test/Generics/variadic_generic_requirements.swift +++ b/test/Generics/variadic_generic_requirements.swift @@ -30,8 +30,8 @@ struct Outer { } _ = Outer, Array>.Inner, Set>.self // ok -_ = Outer, Array>.Inner, Set>.self // expected-error {{'Outer, Array>.Inner' requires the types 'Pack{Int, String}' and 'Pack{String, Int}' be equivalent}} -_ = Outer>.Inner, Set>.self // expected-error {{'Outer>.Inner' requires the types 'Pack{Int}' and 'Pack{Int, String}' be equivalent}} +_ = Outer, Array>.Inner, Set>.self // expected-error {{'Outer, Array>.Inner' requires the types 'Int, String' and 'String, Int' be equivalent}} +_ = Outer>.Inner, Set>.self // expected-error {{'Outer>.Inner' requires the types 'Int' and 'Int, String' be equivalent}} _ = Outer, Array>.InnerShape, Set>.self // ok -_ = Outer>.InnerShape, Set>.self // expected-error {{'Outer>.InnerShape' requires the type packs 'Pack{Array}' and 'Pack{Set, Set}' have the same shape}} +_ = Outer>.InnerShape, Set>.self // expected-error {{'Outer>.InnerShape' requires the type packs 'Array' and 'Set, Set' have the same shape}} diff --git a/test/IRGen/pack_metadata_marker_inserter.sil b/test/IRGen/pack_metadata_marker_inserter.sil index 28dab57181efa..a8eefd5e2af3f 100644 --- a/test/IRGen/pack_metadata_marker_inserter.sil +++ b/test/IRGen/pack_metadata_marker_inserter.sil @@ -108,7 +108,6 @@ sil @forward_type_pack : $() -> () { // CHECK-LLVM-SAME: i8* [[LIFETIME_START_CAST]]) // CHECK-LLVM: [[LIFETIME_END_CAST:%[^,]+]] = bitcast [3 x %swift.type*]* [[PACK_ADDR]] to i8* // CHECK-LLVM: call void @llvm.lifetime.end.p0i8( -// CHECK-LLVM-SAME: [[INT]] 24, // CHECK-LLVM-SAME: i8* [[LIFETIME_END_CAST]]) // CHECK-LLVM: ret void // CHECK-LLVM: } diff --git a/test/Interop/Cxx/enum/Inputs/c-enums-NS_OPTIONS.h b/test/Interop/Cxx/enum/Inputs/c-enums-NS_OPTIONS.h index 55c80c929b1e8..6df2e9e843654 100644 --- a/test/Interop/Cxx/enum/Inputs/c-enums-NS_OPTIONS.h +++ b/test/Interop/Cxx/enum/Inputs/c-enums-NS_OPTIONS.h @@ -20,16 +20,13 @@ extern "C" { #define NS_REFINED_FOR_SWIFT __attribute__((swift_private)) #define UIKIT_EXTERN extern "C" __attribute__((visibility("default"))) -typedef unsigned long NSUInteger; -typedef long NSInteger; - -typedef NS_OPTIONS(NSUInteger, NSBinarySearchingOptions) { +typedef NS_OPTIONS(unsigned long, NSBinarySearchingOptions) { NSBinarySearchingFirstEqual = (1UL << 8), NSBinarySearchingLastEqual = (1UL << 9), NSBinarySearchingInsertionIndex = (1UL << 10), }; -typedef NS_OPTIONS(NSUInteger, NSAttributedStringFormattingOptions) { +typedef NS_OPTIONS(unsigned long, NSAttributedStringFormattingOptions) { NSAttributedStringFormattingInsertArgumentAttributesWithoutMerging = 1 << 0, NSAttributedStringFormattingApplyReplacementIndexAttribute = 1 << 1, } NS_REFINED_FOR_SWIFT; @@ -45,7 +42,7 @@ typedef NS_OPTIONS(NSUInteger, NSAttributedStringFormattingOptions) { UIKIT_EXTERN @interface UIPrinter -typedef NS_OPTIONS(NSInteger, UIPrinterJobTypes) { +typedef NS_OPTIONS(long, UIPrinterJobTypes) { UIPrinterJobTypeUnknown = 0, UIPrinterJobTypeDocument = 1 << 0, UIPrinterJobTypeEnvelope = 1 << 1, @@ -60,7 +57,7 @@ typedef NS_OPTIONS(NSInteger, UIPrinterJobTypes) { @end } -typedef NS_OPTIONS(NSUInteger, Foo) { +typedef NS_OPTIONS(unsigned long, Foo) { NS_SWIFT_NAMED_OptionOne __attribute__((swift_name("SwiftOptionOne"))) = 0, NS_SWIFT_NAMED_OptionTwo __attribute__((swift_name("SwiftOptionTwo"))) = 1 << 0, @@ -71,7 +68,7 @@ typedef NS_OPTIONS(NSUInteger, Foo) { NS_SWIFT_NAMED_OptionTwo }; -typedef NS_OPTIONS(NSUInteger, Bar) { +typedef NS_OPTIONS(unsigned long, Bar) { API_NOTES_NAMED_OptionOne = 0, API_NOTES_NAMED_OptionTwo = 1 << 0, API_NOTES_NAMED_OptionThree = 1 << 1, @@ -79,7 +76,7 @@ typedef NS_OPTIONS(NSUInteger, Bar) { API_NOTES_NAMED_OptionTwo }; -typedef NS_OPTIONS(NSUInteger, Baz) { Baz1, Baz2 }; +typedef NS_OPTIONS(unsigned long, Baz) { Baz1, Baz2 }; struct HasNSOptionField { Bar bar; diff --git a/test/Interpreter/Inputs/layout_string_witnesses_types.swift b/test/Interpreter/Inputs/layout_string_witnesses_types.swift index 5847702ce5195..1eb45df5b93d2 100644 --- a/test/Interpreter/Inputs/layout_string_witnesses_types.swift +++ b/test/Interpreter/Inputs/layout_string_witnesses_types.swift @@ -442,6 +442,10 @@ public struct InternalEnumWrapper { } } +public enum SingletonEnum { + case only(T, Int) +} + public enum SinglePayloadEnumManyXI { case empty0 case empty1 diff --git a/test/Interpreter/layout_string_witnesses_dynamic.swift b/test/Interpreter/layout_string_witnesses_dynamic.swift index cf402abf8ef8c..3bf1c64fa382b 100644 --- a/test/Interpreter/layout_string_witnesses_dynamic.swift +++ b/test/Interpreter/layout_string_witnesses_dynamic.swift @@ -243,6 +243,34 @@ func testGenericEnum() { testGenericEnum() +func testGenericEnumSingleton() { + let ptr = allocateInternalGenericPtr(of: SingletonEnum.self) + + do { + let x = TestClass() + testGenericInit(ptr, to: SingletonEnum.only(x, 23)) + } + + do { + let y = TestClass() + // CHECK: Before deinit + print("Before deinit") + + // CHECK-NEXT: TestClass deinitialized! + testGenericAssign(ptr, from: SingletonEnum.only(y, 32)) + } + + // CHECK-NEXT: Before deinit + print("Before deinit") + + // CHECK-NEXT: TestClass deinitialized! + testGenericDestroy(ptr, of: SingletonEnum.self) + + ptr.deallocate() +} + +testGenericEnumSingleton() + func testRecursive() { let ptr = allocateInternalGenericPtr(of: Recursive.self) diff --git a/utils/build-presets.ini b/utils/build-presets.ini index 745ef816f59fe..c0c5ed5262643 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -670,6 +670,13 @@ skip-build-benchmarks # Skip playground tests skip-test-playgroundsupport +# Skip downstream project tests +skip-test-swiftsyntax +skip-test-indexstore-db +skip-test-sourcekit-lsp +skip-test-swiftpm +skip-test-llbuild + [preset: buildbot_incremental,tools=RA,stdlib=RD,smoketest=macosx,flto] mixin-preset=buildbot_incremental,tools=RA,stdlib=RD,smoketest=macosx build-subdir=buildbot_incremental diff --git a/utils/build-script-impl b/utils/build-script-impl index dafe4aeaff44c..21712a923143b 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -452,7 +452,8 @@ function should_execute_host_actions_for_phase() { function verify_host_is_supported() { local host="$1" case ${host} in - freebsd-x86_64 \ + freebsd-arm64 \ + | freebsd-x86_64 \ | openbsd-amd64 \ | cygwin-x86_64 \ | haiku-x86_64 \ diff --git a/utils/swift_build_support/swift_build_support/cmake.py b/utils/swift_build_support/swift_build_support/cmake.py index 3a82184af2b85..61e255e759fbd 100644 --- a/utils/swift_build_support/swift_build_support/cmake.py +++ b/utils/swift_build_support/swift_build_support/cmake.py @@ -283,11 +283,11 @@ def build_cmake(self, source_root, build_root): os.chdir(cwd) return os.path.join(cmake_build_dir, 'bin', 'cmake') - # For Linux only, determine the version of the installed CMake compared to - # the source and build the source if necessary. Returns the path to the - # cmake binary. + # For Linux and FreeBSD only, determine the version of the installed + # CMake compared to the source and build the source if necessary. + # Returns the path to the cmake binary. def check_cmake_version(self, source_root, build_root): - if platform.system() != 'Linux': + if not platform.system() in ["Linux", "FreeBSD"]: return cmake_source_dir = os.path.join(source_root, 'cmake') diff --git a/utils/swift_build_support/swift_build_support/shell.py b/utils/swift_build_support/swift_build_support/shell.py index d50c12788c450..a2d33c06e4c22 100644 --- a/utils/swift_build_support/swift_build_support/shell.py +++ b/utils/swift_build_support/swift_build_support/shell.py @@ -228,8 +228,10 @@ def run(*args, **kwargs): my_pipe = subprocess.Popen( *args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, + encoding='utf-8', **kwargs) (output, _) = my_pipe.communicate() + output = output.encode(encoding='ascii', errors='replace') ret = my_pipe.wait() if lock: diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 4d524bbe6e95a..5bafdaf8260ba 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -277,7 +277,7 @@ class StdlibDeploymentTarget(object): "powerpc64le", "s390x"]) - FreeBSD = Platform("freebsd", archs=["x86_64"]) + FreeBSD = Platform("freebsd", archs=["x86_64", "arm64"]) OpenBSD = OpenBSDPlatform("openbsd", archs=["amd64"]) @@ -375,6 +375,8 @@ def host_target(): elif system == 'FreeBSD': if machine == 'amd64': return StdlibDeploymentTarget.FreeBSD.x86_64 + elif machine == 'arm64': + return StdlibDeploymentTarget.FreeBSD.arm64 elif system == 'OpenBSD': if machine == 'amd64':