[PATCH] D65256: [Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership qualifications as unavailable if the union is declared in a system header

Jordan Rose via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 25 10:26:28 PDT 2019


jordan_rose added a comment.

In D65256#1601410 <https://reviews.llvm.org/D65256#1601410>, @rjmccall wrote:

> These were unavailable in system headers before because otherwise we would've had to make them invalid.  Since these unions are no longer otherwise invalid, there shouldn't be a problem with allowing them in system headers, and in fact making the semantics vary that way seems quite problematic.  Now, specific *uses* in system headers might still appear to be invalid — e.g. an ObjC ivar of type `union { __strong id x; }` — and the right behavior is definitely that those use sites should be marked as invalid instead of refusing to compile the system header.


That's the right answer on paper, but it's source-breaking in practice, for both Swift and Objective-C. On the Objective-C side, someone could have been using, say, `glob_t` in a copyable way in their ARC code, never touching the block field, and it would have been working fine. On the Swift side, we won't be able to import such a union at all when previously we would have.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65256/new/

https://reviews.llvm.org/D65256





More information about the cfe-commits mailing list