diff options
author | fahadnayyar <30953967+fahadnayyar@users.noreply.github.com> | 2025-05-07 13:42:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-07 13:42:39 -0700 |
commit | 62a2f0fdc74f086c875833eefe9099bd30f41957 (patch) | |
tree | 02fb0b85bc07c30bc6a8d34587f9c1c7efd8cd68 /clang/lib/Serialization/ModuleManager.cpp | |
parent | 43c514bd42d3e12dd299c0a7165b3e079e9efd38 (diff) | |
download | llvm-62a2f0fdc74f086c875833eefe9099bd30f41957.zip llvm-62a2f0fdc74f086c875833eefe9099bd30f41957.tar.gz llvm-62a2f0fdc74f086c875833eefe9099bd30f41957.tar.bz2 |
[APINotes] Add support for SWIFT_RETURED_AS_UNRETAINED_BY_DEFAULT (#138699)
This patch adds support in APINotes for annotating C++ user-defined
types with: `swift_attr("returned_as_unretained_by_default")`
This attribute allows to specify a default ownership convention for
return values of `SWIFT_SHARED_REFERENCE` c++ types. Specifically, it
marks all unannotated return values of this type as `unretained` (`+0`)
by default, unless explicitly overridden at the API level using
`swift_attr("returns_retained")` or `swift_attr("returns_unretained")`.
The corresponding Swift compiler support for this annotation enables
developers to suppress warnings about unannotated return ownership in
large codebases while maintaining safe and predictable ownership
semantics. By enabling this in APINotes, library authors can define this
behavior externally without needing to modify C++ source headers
directly.
### Example usage in APINotes:
```
- Name: RefCountedTypeWithDefaultConvention
SwiftImportAs: reference
SwiftDefaultOwnership: unretained
```
rdar://150764491
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
0 files changed, 0 insertions, 0 deletions