]> granicus.if.org Git - clang/commit
[ObjCARC] Add an new attribute, objc_externally_retained
authorErik Pilkington <erik.pilkington@gmail.com>
Fri, 4 Jan 2019 18:33:06 +0000 (18:33 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Fri, 4 Jan 2019 18:33:06 +0000 (18:33 +0000)
commit6d306af57388db45495728891bccdad0156c2c28
treefc0ec49f75f6c86991b803f71aa97dd7e0634558
parent1188822bbcdd02f816e857f1c15df32d0d8c5336
[ObjCARC] Add an new attribute, objc_externally_retained

This attribute, called "objc_externally_retained", exposes clang's
notion of pseudo-__strong variables in ARC. Pseudo-strong variables
"borrow" their initializer, meaning that they don't retain/release
it, instead assuming that someone else is keeping their value alive.

If a function is annotated with this attribute, implicitly strong
parameters of that function aren't implicitly retained/released in
the function body, and are implicitly const. This is useful to expose
for performance reasons, most functions don't need the extra safety
of the retain/release, so programmers can opt out as needed.

This attribute can also apply to declarations of local variables,
with similar effect.

Differential revision: https://reviews.llvm.org/D55865

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350422 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
docs/AutomaticReferenceCounting.rst
include/clang/AST/Decl.h
include/clang/AST/DeclObjC.h
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGExpr.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaExpr.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CodeGenObjC/externally-retained.m [new file with mode: 0644]
test/Misc/pragma-attribute-supported-attributes-list.test
test/SemaObjC/externally-retained-no-arc.m [new file with mode: 0644]
test/SemaObjC/externally-retained.m [new file with mode: 0644]