Repository: apple/swift
File: test/Interop/C/swiftify-import/Inputs/counted-by-lifetimebound.h (C/C++)

Code before:

int * __counted_by(len) simple(int len, int len2, int * p __counted_by(len2) __lifetimebound);

int * __counted_by(len) shared(int len, int * p __counted_by(len) __lifetimebound);

int * __counted_by(len - offset) complexExpr(int len, int offset, int len2, int * p __counted_by(len2) __lifetimebound);

int * __counted_by(len) _Null_unspecified nullUnspecified(int len, int len2, int * _Null_unspecified p __counted_by(len2) __lifetimebound);

int * __counted_by(len) _Nonnull nonnull(int len, int len2, int * _Nonnull p __counted_by(len2) __lifetimebound);

int * __counted_by(len) _Nullable nullable(int len, int len2, int * _Nullable p __counted_by(len2) __lifetimebound);

typedef struct foo opaque_t;
opaque_t * __counted_by(len) opaque(int len, int len2, opaque_t * p __counted_by(len2) __lifetimebound);

int * __counted_by(len) noncountedLifetime(int len, int * p __lifetimebound);

int * __counted_by(13) _Nullable constant(int * _Nullable p __counted_by_or_null(13) __lifetimebound);

struct EscapableStruct {};
// make sure __lifetimebound is ignored when return value is escapable
struct EscapableStruct lifetimeboundEscapableReturn(int len, int * __counted_by(len) p __lifetimebound);

struct __attribute__((swift_attr("~Escapable"))) NonescapableStruct {};
struct NonescapableStruct lifetimeboundNonescapableReturn(int len, int * __counted_by(len) p __lifetimebound);


Review comment (suggestion):
Can you also add tests where the `lifetimebound` is a on a `~Escapable` type?

Like:

```
struct NonescapableStruct lifetimeboundNonescapableReturn(int len, int * __counted_by(len) p __lifetimebound, NonEscapableStruct s __lifetimebound);
```

Code after:

int * __counted_by(len) simple(int len, int len2, int * p __counted_by(len2) __lifetimebound);

int * __counted_by(len) shared(int len, int * p __counted_by(len) __lifetimebound);

int * __counted_by(len - offset) complexExpr(int len, int offset, int len2, int * p __counted_by(len2) __lifetimebound);

int * __counted_by(len) _Null_unspecified nullUnspecified(int len, int len2, int * _Null_unspecified p __counted_by(len2) __lifetimebound);

int * __counted_by(len) _Nonnull nonnull(int len, int len2, int * _Nonnull p __counted_by(len2) __lifetimebound);

int * __counted_by(len) _Nullable nullable(int len, int len2, int * _Nullable p __counted_by(len2) __lifetimebound);

typedef struct foo opaque_t;
opaque_t * __counted_by(len) opaque(int len, int len2, opaque_t * p __counted_by(len2) __lifetimebound);

int * __counted_by(len) noncountedLifetime(int len, int * p __lifetimebound);

int * __counted_by(13) _Nullable constant(int * _Nullable p __counted_by_or_null(13) __lifetimebound);

struct EscapableStruct {};
// make sure __lifetimebound is ignored when return value is escapable
struct EscapableStruct lifetimeboundEscapableReturn(int len, int * __counted_by(len) p __lifetimebound);

struct __attribute__((swift_attr("~Escapable"))) NonescapableStruct {};
struct NonescapableStruct lifetimeboundNonescapableReturn(int len, int * __counted_by(len) p __lifetimebound);

struct NonescapableStruct lifetimeboundNonescapableReturnDoubleBounds(int len, int * __counted_by(len) p __lifetimebound, struct NonescapableStruct s __lifetimebound);