-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[docs] Add documentation for underscored attributes. #37854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Add documentation for underscored attributes. #37854
Conversation
ee0d46f
to
e9849be
Compare
40b35c0
to
b9ff577
Compare
cc @benrimmington in case you have any suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any underscored Objective-C attributes used by the Clang importer?
b9ff577
to
b14f411
Compare
Great idea to document these! Are there pointers to the document in the code where it implements these? |
No, there are no such links as it's likely they would break when code gets moved around. Searching by the attribute strings and related types that come up seems to give good enough results, I think. For certain attributes, they are not implemented in a single place, they affects lots of things, so pointing to 1-2 places could potentially be misleading. Are there specific attributes that you think would benefit from this treatment? |
Do you mean things like |
Sorry--I wrote "link" but all I meant was a comment, say where these are parsed that would refer the reader to the document. Good question about attributes. The one I hit was Again, I'm really glad you are taking this on. It would have helped me to have this documentation. |
Well, you said pointers -- which I mis-interpreted as links. With comments, I'm not sure of what the value-add is over searching... Consider the example of That said, I'm not super tied to not having links/comments. I'll try to gather feedback from other people to see what they think about the additional value of having comments about implementation. I've added some notes for |
I should have written undocumented Clang attributes, but I don't know if any exist, or if this is the right place to put them. ( |
Sounds good. In my case, I don't always think of searching the docs folder when I am reading the code. And then, there are a lot of docs in there. But if a search in Xcode for "_spi" finds your document, then a comment adds less. |
If there are undocumented Clang attributes (I don't recall any but in case you come up with something), IMO that should be a bug-fix in Clang's documentation, not adding those here (because it's less likely someone will search here). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some additional entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. I added comments wherever I felt qualified to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really excited about this. Learned a few things reading it! I'm made a few grammar/style-related suggestions, but there are also some substantive additions and suggestions thrown in.
@_implements(Q, foo()) | ||
func foo_q() {} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was really cool to see a description of why @_disfavoredOverload
was designed. Similarly here, reference could be made to its (earliest?) use in implementing synthesized conformances to Equatable
and Hashable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not have come across, but I gave background on @_disfavoredOverload
to try to illustrate when it should be used (i.e. to work around a known defect in overload resolution that can't be immediately fixed without breaking source, and particularly to work around that specific bug with literals). If that seemed like cool background info rather than a usage guideline, maybe it should be rephrased.
|
||
## `@_nonoverride` | ||
|
||
Warns when a protocol restates a requirement from another protocol that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about, "Marks a declaration that is not an override of another, required when compiling with the -warn-implicit-overrides
flag, which warns when a protocol restates a requirement from another protocol that it refines without annotating the declaration with either override
or @_nonoverride
."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated wording.
2ab51cd
to
e79f67b
Compare
Co-authored-by: Ben Rimmington <[email protected]>
The historical context is primarily meant to guide usage, not as a fun aside.
384d20c
to
cd13dad
Compare
Fixed merge conflict; this is ready for ~final review, in case anyone has other comments. Barring that, I will land this PR on Monday next week. |
@swift-ci smoke test |
@swift-ci smoke test Linux |
I figured I should at least start a PR instead of being lazy.
Fixes rdar://65258964.