r240185 - Allow the cf_returns_[not_]retained attributes to appear on out-parameters.

Jordan Rose jordan_rose at apple.com
Mon Jun 22 20:15:03 PDT 2015


> On Jun 22, 2015, at 12:06 , Douglas Gregor <dgregor at apple.com> wrote:
> 
>> 
>> On Jun 20, 2015, at 12:55 PM, Aaron Ballman <aaron at aaronballman.com <mailto:aaron at aaronballman.com>> wrote:
>> 
>> On Fri, Jun 19, 2015 at 7:17 PM, Douglas Gregor <dgregor at apple.com <mailto:dgregor at apple.com>> wrote:
>>> Author: dgregor
>>> Date: Fri Jun 19 18:17:46 2015
>>> New Revision: 240185
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=240185&view=rev <http://llvm.org/viewvc/llvm-project?rev=240185&view=rev>
>>> Log:
>>> Allow the cf_returns_[not_]retained attributes to appear on out-parameters.
>>> 
>>> Includes a simple static analyzer check and not much else, but we'll also
>>> be able to take advantage of this in Swift.
>>> 
>>> This feature can be tested for using __has_feature(cf_returns_on_parameters).
>>> 
>>> This commit also contains two fixes:
>>> - Look through non-typedef sugar when deciding whether something is a CF type.
>>> - When (cf|ns)_returns(_not)?_retained is applied to invalid properties,
>>>  refer to "property" instead of "method" in the error message.
>>> 
>>> rdar://problem/18742441 <rdar://problem/18742441>
>>> 
>>> Added:
>>>    cfe/trunk/test/SemaObjC/attr-cf_returns.m
>>> Modified:
>>>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>>    cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
>>>    cfe/trunk/lib/Analysis/CocoaConventions.cpp
>>>    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>>    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>>    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
>>>    cfe/trunk/test/Analysis/retain-release.m
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=240185&r1=240184&r2=240185&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 19 18:17:46 2015
>>> @@ -2751,8 +2751,8 @@ def warn_ns_attribute_wrong_return_type
>>>   "return %select{an Objective-C object|a pointer|a non-retainable pointer}2">,
>>>   InGroup<IgnoredAttributes>;
>>> def warn_ns_attribute_wrong_parameter_type : Warning<
>>> -  "%0 attribute only applies to %select{Objective-C object|pointer}1 "
>>> -  "parameters">,
>>> +  "%0 attribute only applies to "
>>> +  "%select{Objective-C object|pointer|pointer-to-CF-pointer}1 parameters">,
>> 
>> CF-pointer doesn't appear to be a common term in the code base (this
>> is the only diagnostic with it, and we have one comment on it), or on
>> the web. Is there a better term we could use? If not, it's fine, I was
>> mostly curious whether this is a common term of art that users would
>> situationally understand.
> 
> 
> I don’t think we have a better term for this. Jordan, any ideas?

I think the official name would be "CF object pointer" or "CF object reference", or "Core Foundation" spelled out in full, but given how it's a descriptor for "parameters" I'm concerned about making it much longer than what's already there. I think it will make sense in practice.

Jordan

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


More information about the cfe-commits mailing list