When applied to out-parameters, the attributes specify the expected lifetime of the written-into object.
Additionally, introduce OSReturnsRetainedOn(Non)Zero attributes, which specify that an ownership transfer happens depending on a return code.
Paths
| Differential D56292
[attributes] Extend os_returns_(not_?)_retained attributes to parameters. ClosedPublic Authored by george.karpenkov on Jan 3 2019, 2:43 PM.
Details Summary When applied to out-parameters, the attributes specify the expected lifetime of the written-into object. Additionally, introduce OSReturnsRetainedOn(Non)Zero attributes, which specify that an ownership transfer happens depending on a return code.
Diff Detail Event Timelinegeorge.karpenkov added a child revision: D56240: [analyzer] Support for OSObjects out parameters in RetainCountChecker.
george.karpenkov marked 6 inline comments as done. george.karpenkov retitled this revision from [attributes] Extend os_returns_(not_?)_retained attributes to parameters to [attributes] Extend os_returns_(not_?)_retained attributes to parameters.. Comment ActionsAddressed comments, added conditional out parameters.
george.karpenkov marked 9 inline comments as done. george.karpenkov added inline comments.
Comment Actions @aaron.ballman I'm half-tempted to rewrite most of attribute handling to just have a single attribute class with multiple spelling, and then I would be able to differentiate between them without meta-programming template trickery. What do you think? Comment Actions OTOH using a single attribute class for all attributes makes usage from Sema very unwieldy, Comment Actions LGTM aside from some minor nits.
This revision is now accepted and ready to land.Jan 11 2019, 5:35 AM Closed by commit rL350942: [attributes] Extend os_returns_(not_?)_retained attributes to parameters (authored by george.karpenkov). · Explain WhyJan 11 2019, 10:05 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 180701 clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-osobject.cpp
clang/test/Sema/attr-osobject.mm
|
The documentation should be updated to mention this change.