diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index f41f4ef847ee3..3a00f1562d3a8 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -2762,7 +2762,6 @@ ModuleDecl *ModuleFile::getModule(ImportPath::Module name, return getContext().getLoadedModule(name); } - /// Translate from the Serialization associativity enum values to the AST /// strongly-typed enum. /// @@ -5280,6 +5279,11 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl &scratch, isPackageDescriptionVersionSpecific, isSPI, LIST_VER_TUPLE_PIECES(Introduced), LIST_VER_TUPLE_PIECES(Deprecated), LIST_VER_TUPLE_PIECES(Obsoleted), platform, renameDeclID, messageSize, renameSize); + + // Hack: Filter the un-supported platforms from swiftmodule + if (platform >= /*PlatformKind::visionOS*/13) { + return nullptr; + } ValueDecl *renameDecl = nullptr; if (renameDeclID) { @@ -5513,6 +5517,7 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() { case decls_block::Available_DECL_ATTR: { Attr = readAvailable_DECL_ATTR(scratch, blobData); + if (!Attr) skipAttr = true; break; } @@ -5625,10 +5630,20 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() { } auto attr = readAvailable_DECL_ATTR(scratch, blobData); - availabilityAttrs.push_back(attr); + if (attr) { + availabilityAttrs.push_back(attr); + } restoreOffset2.cancel(); --numAvailabilityAttrs; } + + // Hack: When deserialized from some un-supported @available attr decl, we should remove it + // @available (iOS, macOS, visionOS) -> @available (iOS, macOS) + if (availabilityAttrs.empty()) { + // If attr list is empty, then remove this attr + skipAttr = true; + break; + } auto specializedSig = MF.getGenericSignature(specializedSigID); Attr = SpecializeAttr::create(ctx, exported != 0, specializationKind,