[clang] [APINotes] Add SWIFT_RETURNS_(UN)RETAINED support (PR #118938)

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 16:48:03 PST 2024


================
@@ -373,6 +373,13 @@ void ReadFunctionInfo(const uint8_t *&Data, FunctionInfo &Info) {
       endian::readNext<uint16_t, llvm::endianness::little>(Data);
   Info.ResultType = std::string(Data, Data + ResultTypeLen);
   Data += ResultTypeLen;
+
+  unsigned SwiftReturnOwnershipLength =
+      endian::readNext<uint16_t, llvm::endianness::little>(Data);
+  Info.SwiftReturnOwnership = std::string(reinterpret_cast<const char *>(Data),
+                                          reinterpret_cast<const char *>(Data) +
+                                              SwiftReturnOwnershipLength);
----------------
compnerd wrote:

`ReturnType` is not the same category - the return type of a function can be any UDT. We have an explicit set of permissible ownership models.

Handling both `SWIFT_SHARED_REFERENCE` and this together does make sense.

https://github.com/llvm/llvm-project/pull/118938


More information about the cfe-commits mailing list