16 Commits

Author SHA1 Message Date
Björn Pettersson
26f5d1ee9c
[APINotes] Avoid assertion failure with expensive checks (#120487)
Found assertion failures when using EXPENSIVE_CHECKS and running lit
tests for APINotes:
Assertion `left.first != right.first && "two entries for the same
version"' failed.

It seems like std::is_sorted is verifying that the comparison function
is reflective (comp(a,a)=false) when using expensive checks. So we would
get callbacks to the lambda used for comparison, even for vectors with a
single element in APINotesReader::VersionedInfo<T>::VersionedInfo, with
"left" and "right" being the same object. Therefore the assert checking
that we never found equal values would fail.

Fix makes sure that we skip the check for equal values when "left" and
"right" is the same object.
2024-12-18 23:36:45 +01:00
fahadnayyar
48f7f63ac7
[APINotes] Add SWIFT_RETURNS_(UN)RETAINED support (#118938)
Adding support to APINotes to annotate C++ methods and functions with
`swift_attr("returns_retained")` and `swift_attr("returns_unretained")`

rdar://141007510
2024-12-09 15:37:09 -08:00
Gábor Horváth
d2db9bd708
[clang][APINotes] Add support for the SwiftEscapable attribute (#115866)
This is similar to SwiftCopyable. Also fix missing SwiftCopyable dump
for TagInfo.
2024-11-12 21:34:56 +00:00
Gábor Horváth
5f4e3a3ced
[clang] Support 'this' position for lifetimebound attribute (#115021)
This patch makes the position -1 interpreted as the position for 'this'.
Adds some basic infrastructure and support for lifetimebound attribute.
2024-11-07 17:54:04 +00:00
Gábor Horváth
7ac78f1342
[clang] Add preliminary lifetimebound support to APINotes (#114830) 2024-11-04 20:29:56 +00:00
Egor Zhdan
b81697718f
[APINotes] Support fields of C/C++ structs
This allows annotating fields of C/C++ structs using API Notes.

Previously API Notes supported Objective-C properties, but not fields.

rdar://131548377
2024-08-16 18:48:39 +01:00
Egor Zhdan
dc8c217db6
[APINotes] Support C++ tag conformances to Swift protocols
This allows adding a Clang attribute
`swift_attr("conforms_to:ModuleName.ProtocolName")` to C++ structs via
API Notes.

The Swift compiler respects this attribute when importing C++ types into
Swift by automatically declaring the C++ type as a conforming type to
the given Swift protocol.

rdar://131388824
2024-08-13 12:47:23 +01:00
Egor Zhdan
8a79dc7e6f
[APINotes] Support annotating C++ methods
This adds support for adding Clang attributes to C++ methods declared
within C++ records by using API Notes.

For instance:
```
Tags:
- Name: IntWrapper
  Methods:
  - Name: getIncremented
    Availability: none
```

This is the first instance of something within a C++ record being
annotated with API Notes, so it adds the necessary infra to make a C++
record an "API Notes context".

Notably this does not add support for nested C++ tags. That will be
added in a follow-up patch.

rdar://131387880
2024-07-19 13:35:13 +01:00
Egor Zhdan
c5f402f95d
[APINotes] Reduce memory footprint for Obj-C/C++ contexts
We were storing extraneous data for certain Objective-C/C++ entities.
Specifically, for declarations that can be nested in another context
(such as functions) we were storing the kind of the parent context in
addition to its ID. The ID is always sufficient.

This removes the logically incorrect usages of `ContextTableKey` that
don't actually describe a context, but rather describe a single
declaration. This introduces `SingleDeclTableKey` to store that kind of
entities in a more compact and reasonable way.
2024-07-18 13:27:24 +01:00
Egor Zhdan
82ee7ae3c9
[APINotes] Refactor: remove references to ObjCContext...
API Notes now support in C++. In preparation for supporting C++ methods
in API Notes, this change renames the remaining usages of
`ObjCContextABC` into `ContextABC` to make it clear that those contexts
might actually be C++, not Objective-C.

This is NFC-ish.
2024-07-10 15:07:09 +01:00
Egor Zhdan
b2098db248
[APINotes] Allow annotating a C++ type as non-copyable in Swift
Certain C++ types, such as `std::chrono::tzdb` in libstdc++, are
non-copyable, but don't explicitly delete their copy constructor.
Instead, they trigger template instantiation errors when trying to call
their implicit copy constructor. The Swift compiler inserts implicit
copies of value types in some cases, which trigger compiler errors for
such types.

This adds a Clang API Notes attribute that allows annotating C++ types
as non-copyable in Swift. This lets the Swift compiler know that it
should not try to instantiate the implicit copy constructor for a C++
struct.

rdar://127049438
2024-04-26 19:30:08 +01:00
Kazu Hirata
89071f3559
[clang] Drop unaligned from calls to readNext (NFC) (#88842)
Now readNext defaults to unaligned accesses.  This patch drops
unaligned to improve readability.
2024-04-16 00:09:41 -07:00
Jan Svoboda
864593b91d [clang][api-notes] NFC: Upstream some documentation 2024-03-01 16:53:12 -08:00
Egor Zhdan
5e4c4365f8
[APINotes] Fix a few accidental refactoring artifacts
This fixes a few breakages introduced during upstreaming.
2024-02-27 00:37:15 +00:00
Egor Zhdan
41021e8ef8
[APINotes] Upstream APINotes YAML compiler
This upstreams more of the Clang API Notes functionality that is
currently implemented in the Apple fork:
https://github.com/apple/llvm-project/tree/next/clang/lib/APINotes
2023-11-13 19:36:36 +00:00
Egor Zhdan
bb352b6ead
[APINotes] Upstream APINotesReader
This upstreams more of the Clang API Notes functionality that is
currently implemented in the Apple fork:
https://github.com/apple/llvm-project/tree/next/clang/lib/APINotes
2023-10-30 14:36:44 +00:00