[cfe-commits] r79040 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/attr-malloc.m

Ted Kremenek kremenek at apple.com
Fri Aug 14 14:56:09 PDT 2009


On Aug 14, 2009, at 2:48 PM, Eli Friedman wrote:

> On Fri, Aug 14, 2009 at 1:49 PM, Ted Kremenek<kremenek at apple.com>  
> wrote:
>> @@ -431,17 +438,18 @@
>>     return;
>>   }
>>
>> -  if (!isFunctionOrMethod(d)) {
>> +  if (!isFunction(d)) {
>>     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
>>       << Attr.getName() << 0 /*function*/;
>>     return;
>>   }
>>
>> -  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
>> -    if (!FD->getResultType()->isPointerType()) {
>> -      S.Diag(Attr.getLoc(),  
>> diag::warn_attribute_malloc_pointer_only);
>> -      return;
>> -    }
>> +  const FunctionDecl *FD = cast<FunctionDecl>(d);
>> +  QualType RetTy = FD->getResultType();
>> +
>> +  if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) {
>> +    S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
>> +    return;
>>   }
>
> I believe we went through this before... isFunction doesn't guarantee
> that d is a FunctionDecl.

In the previous discussion, the code involved 'isFunctionOrMethod',  
which would return true for an ObjCMethodDecl.  I just added  
'isFunction'.  When I read the previous objections to  
cast<FunctionDecl>, I thought it was mainly because the Decl could be  
an ObjCMethodDecl, but as you pointed out in your other email they are  
certainly other cases.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090814/ea06f8a2/attachment.html>


More information about the cfe-commits mailing list