[cfe-commits] r160900 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/arc-bridged-cast.m test/SemaObjC/arc-cf.m test/SemaObjC/arc-unbridged-cast.m test/SemaObjCXX/arc-unbridged-cast.mm

jahanian fjahanian at apple.com
Fri Jul 27 16:23:43 PDT 2012


On Jul 27, 2012, at 3:49 PM, Jordan Rose wrote:

> Hm. Here's that whole function (before the change):
> 
> ACCResult checkCallToFunction(FunctionDecl *fn) {
>   // Require a CF*Ref return type.
>   if (!isCFType(fn->getResultType()))
>     return ACC_invalid;
> 
>   if (!isAnyRetainable(TargetClass))
>     return ACC_invalid;
> 
>   // Honor an explicit 'not retained' attribute.
>   if (fn->hasAttr<CFReturnsNotRetainedAttr>())
>     return ACC_plusZero;
> 
>   // Honor an explicit 'retained' attribute, except that for
>   // now we're not going to permit implicit handling of +1 results,
>   // because it's a bit frightening.
>   if (fn->hasAttr<CFReturnsRetainedAttr>())
>     return ACC_invalid; // ACC_plusOne if we start accepting this
> 
>   // Recognize this specific builtin function, which is used by CFSTR.
>   unsigned builtinID = fn->getBuiltinID();
>   if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
>     return ACC_bottom;
> 
>   // Otherwise, don't do anything implicit with an unaudited function.
>   if (!fn->hasAttr<CFAuditedTransferAttr>())
>     return ACC_invalid;
> 
>   // Otherwise, it's +0 unless it follows the create convention.
>   if (ento::coreFoundation::followsCreateRule(fn))
>     return ACC_invalid; // ACC_plusOne if we start accepting this
> 
>   return ACC_plusZero;
> }
> 
> I wonder if leaving the "followsCreateRule" after the CFAuditedTransferAttr check would be better; relying on the naming convention for un-audited code may be a bad idea even

If I leave it after, then CFAuditedTransferAttr check would not get me to check for the naming convention. Note that since in the non-diagnose case they both return
ACC_invalid, this will not change the behavior.


> for fixits. On the other hand, we can go ahead and turn on the CFReturnsRetainedAttr case (for diagnostics only, of course), since if that attribute was added the semantics of the function have implicitly been audited.
OK.

> 
> On the plus side, you should be able to check for ACC_plusZero as well, and only suggest __bridge in that case.
OK.

- Fariborz

> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120727/3884e498/attachment.html>


More information about the cfe-commits mailing list