From 3877eb8bc9592b866a3f1a94ba143b9024a91225 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Wed, 30 Oct 2024 17:08:20 +0100 Subject: [PATCH] Swift: tentatively fix type mangling --- swift/extractor/mangler/SwiftMangler.cpp | 30 +++++++++++++++++------- swift/third_party/load.bzl | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/swift/extractor/mangler/SwiftMangler.cpp b/swift/extractor/mangler/SwiftMangler.cpp index bb8f63c232ee..3743ab53dcad 100644 --- a/swift/extractor/mangler/SwiftMangler.cpp +++ b/swift/extractor/mangler/SwiftMangler.cpp @@ -197,19 +197,30 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType auto ret = initMangled(type); for (const auto& param : type->getParams()) { ret << fetch(param.getPlainType()); - if (param.isInOut()) { - ret << "_inout"; + auto flags = param.getParameterFlags(); + ret << "_" << getNameForParamSpecifier(flags.getOwnershipSpecifier()); + if (flags.isIsolated()) { + ret << "_isolated"; } - if (param.isOwned()) { - ret << "_owned"; + if (flags.isAutoClosure()) { + ret << "_autoclosure"; } - if (param.isShared()) { - ret << "_shared"; + if (flags.isNonEphemeral()) { + ret << "_nonephermeral"; } - if (param.isIsolated()) { + if (flags.isIsolated()) { ret << "_isolated"; } - if (param.isVariadic()) { + if (flags.isSending()) { + ret << "_sending"; + } + if (flags.isCompileTimeConst()) { + ret << "_compiletimeconst"; + } + if (flags.isNoDerivative()) { + ret << "_noderivative"; + } + if (flags.isVariadic()) { ret << "..."; } } @@ -219,6 +230,9 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType } if (type->isThrowing()) { ret << "_throws"; + if (type->hasThrownError()) { + ret << "(" << fetch(type->getThrownError()) << ")"; + } } if (type->isSendable()) { ret << "_sendable"; diff --git a/swift/third_party/load.bzl b/swift/third_party/load.bzl index 0df011791a6c..312e7e84221b 100644 --- a/swift/third_party/load.bzl +++ b/swift/third_party/load.bzl @@ -6,7 +6,7 @@ load("//misc/bazel:lfs.bzl", "lfs_archive", "lfs_files") _override = { # these are used to test new artifacts. Must be empty before merging to main "swift-prebuilt-macOS.tar.zst": "a016ed60ee1a534439ed4d55100ecf6b9fc739f629be20942345ac5156cb6296", - "swift-prebuilt-Linux.tar.zst": "54240eb2da948207862ea8eb9bcbfe4447016534b9a8e6d8ee1af67db2a3e73f", + "swift-prebuilt-Linux.tar.zst": "c45976d50670964132cef1dcf98bccd3fff809d33b2207a85cf3cfd07ec84528", "resource-dir-macOS.zip": "286e4403aa0a56641c2789e82036481535e336484f2c760bec0f42e3afe5dd87", "resource-dir-Linux.zip": "16a1760f152395377a580a994885e0877338279125834463a6a38f4006ad61ca", }