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

Douglas Gregor dgregor at apple.com
Mon Jun 22 12:06:37 PDT 2015


> On Jun 20, 2015, at 12:55 PM, Aaron Ballman <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
>> 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
>> 
>> 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?

	- Doug

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


More information about the cfe-commits mailing list