This is an archive of the discontinued LLVM Phabricator instance.

[clang] add a new `swift_attr` attribute
ClosedPublic

Authored by arphaman on Nov 30 2020, 4:11 PM.

Details

Summary

The swift_attr attribute is a generic annotation attribute that's not used by clang, but is used by the Swift compiler. The Swift compiler can use these annotations to provide various syntactic and semantic sugars for the imported Objective-C API declarations.

Diff Detail

Event Timeline

arphaman created this revision.Nov 30 2020, 4:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2020, 4:11 PM
arphaman requested review of this revision.Nov 30 2020, 4:11 PM

Do we need to add APINotes support for this?

clang/include/clang/Basic/Attr.td
2155

Should we limit this to appear on certain subjects? Presumably the swift importer is only going to look for this in certain places, so I think it makes sense to call out places where it'll be ignored in clang. WDYT?

aaron.ballman added inline comments.Dec 2 2020, 11:53 AM
clang/include/clang/Basic/Attr.td
2153

The other swift attributes use a GNU spelling and don't expose any C++ spelling. Should this follow suit (or should the other attributes be updated)?

clang/include/clang/Basic/AttrDocs.td
3635

What declarations does this attribute appertain to?

3637

clang -> Clang

arphaman updated this revision to Diff 309553.Dec 4 2020, 9:28 AM
arphaman marked 2 inline comments as done.

Updated for review comments

Thanks for taking a look.

Do we need to add APINotes support for this?

Not at the moment, maybe in the future

clang/include/clang/Basic/Attr.td
2153

You're right, that was my mistake. Changed it to GNU.

2155

I think we want to leave it as a flexible attribute that can be applied to any declaration for now, and let the Swift importer decide on which declarations it wants to support them.

clang/include/clang/Basic/AttrDocs.td
3635

Mentioned that it can be applied to any declaration.

This revision is now accepted and ready to land.Dec 4 2020, 12:54 PM
This revision was automatically updated to reflect the committed changes.