diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2019-01-04 18:33:06 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2019-01-04 18:33:06 +0000 |
commit | 1e36882b5291d5a7209be4f9c99b9713828afac4 (patch) | |
tree | cd23171fec5d69fd0390b0ad9303f51396072b5c /clang/lib/Sema/SemaExpr.cpp | |
parent | 6153565511338f33506f4615dd5a7d2e4c4ffaa6 (diff) | |
download | bcm5719-llvm-1e36882b5291d5a7209be4f9c99b9713828afac4.tar.gz bcm5719-llvm-1e36882b5291d5a7209be4f9c99b9713828afac4.zip |
[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
llvm-svn: 350422
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index aa4b23b15c5..eddf90178bc 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11214,17 +11214,23 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { if (var->isARCPseudoStrong() && (!var->getTypeSourceInfo() || !var->getTypeSourceInfo()->getType().isConstQualified())) { - // There are two pseudo-strong cases: + // There are three pseudo-strong cases: // - self ObjCMethodDecl *method = S.getCurMethodDecl(); - if (method && var == method->getSelfDecl()) + if (method && var == method->getSelfDecl()) { DiagID = method->isClassMethod() ? diag::err_typecheck_arc_assign_self_class_method : diag::err_typecheck_arc_assign_self; + // - Objective-C externally_retained attribute. + } else if (var->hasAttr<ObjCExternallyRetainedAttr>() || + isa<ParmVarDecl>(var)) { + DiagID = diag::err_typecheck_arc_assign_externally_retained; + // - fast enumeration variables - else + } else { DiagID = diag::err_typecheck_arr_assign_enumeration; + } SourceRange Assign; if (Loc != OrigLoc) |