This adds the __swift_objc_members__ attribute to the semantic
analysis. It allows for annotating ObjC interfaces to provide Swift
semantics indicating that the types derived from this interface will be
back-bridged to Objective-C to allow interoperability with Objective-C
and Swift.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/Basic/Attr.td | ||
---|---|---|
2133 | Should this be inherited by redeclarations, or is that not a thing with ObjCInterfaceDecls? | |
clang/include/clang/Basic/AttrDocs.td | ||
3482 | The documentation is a bit hard to follow -- the user is going to be adding this attribute to an ObjC interface, so the docs should be talking about what that means from the ObjC side of things more so than the Swift side, no? | |
clang/lib/Sema/SemaDeclAttr.cpp | ||
7540 | Does it matter if the user writes this attribute on an interface that exposes no members? e.g., are there warnings we may want to give the user about using the attribute in a weird way? (Sorry if this should be obvious, but I don't have experience with Swift.) | |
clang/test/SemaObjC/attr-swift_objc_members.m | ||
5 | The typo fix makes sense to me, but for my own understanding, why switch to a string literal? |
clang/include/clang/Basic/AttrDocs.td | ||
---|---|---|
3482 | It may not have semantic impact on the ObjC side of things, but I'd still expect that since the user is writing it on an ObjC entity, the docs talk about it from that perspective. e.g., I'd expect the documentation to be more along the lines of "The attribute indicates that the members of this Objective-C class/protocol/whatever, its subclasses and so on, will be exposed as Swift class members that do the awesome thing." instead of "In Swift, this other attribute does things similar to what this one does in Objective-C." | |
clang/test/SemaObjC/attr-swift_objc_members.m | ||
5 | Interesting and somewhat different from my understanding. My mental model for #error is that it "replays" the tokens into the diagnostic message up to the end of the line. Given that I prefer my diagnostics to be warning: you did the wrong thing and not warning: "you did the wrong thing" (with quotes), I usually leave the quotes off so that the error looks more consistent with other errors. Neither form is more right than the other in this case, so I don't really care for this review (I was interested in it as a standards committee member who recently had to look at the specification for #error though). |
clang/include/clang/Basic/AttrDocs.td | ||
---|---|---|
3482 | Sure, how about this: "This attribute indicates that Swift subclasses and members of Swift extensions of this class will be implicitly marked with the `@objcMembers` Swift attribute." (This attribute has no effect on this class itself or its members, even when imported in Swift -- only on Swift extensions & subclasses.) |
clang/include/clang/Basic/AttrDocs.td | ||
---|---|---|
3482 | That sounds better to me, thank you! |
clang/include/clang/Basic/Attr.td | ||
---|---|---|
2133 | Objective-C interfaces cannot be redeclared, so this actually is correct I believe. | |
clang/lib/Sema/SemaDeclAttr.cpp | ||
7540 | I think that the name is not exactly helpful in this case, but that ship has sailed since this is in production already. AIUI the attribute should apply to empty interfaces as it results in the Swift interface being exposed back to Objective-C. | |
clang/test/SemaObjC/attr-swift_objc_members.m | ||
5 | FWIW, the reason for the warning not being quoted currently is exactly what @aaron.ballman stated ... that is how I process the #error directive as well, and I tend to leave the quotes off to make the error match the other diagnostics. Is the quoting really that important? |
clang/test/SemaObjC/attr-swift_objc_members.m | ||
---|---|---|
5 | No, not at all important. |
Should this be inherited by redeclarations, or is that not a thing with ObjCInterfaceDecls?