[cfe-dev] [Patch] Generate a warning if a message is sent to a nil receiver with return type larger than void* (PR 2718)
Nikita Zhuk
nikita at zhuk.fi
Wed Apr 8 01:43:14 PDT 2009
On 8.4.2009, at 4.42, Ted Kremenek wrote:
> Hi Nikita,
>
> This looks great. Just to confirm, I think the particular reference
> to the Apple documentation is the following:
>
> http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/universal_binary_tips/universal_binary_tips.html#/
> /apple_ref/doc/uid/TP40002217-CH239-CJBJABFC
Yes, that's the correct one.
I have a question related to the nil receiver checks. Would it be
possible to take the nil receiver assumption (ObjC messages with size
of return value <= sizeof(void*) sent to nil always return zero) into
account in GRExprEngine, so that the number of false positives could
be reduced even further? For example, the following cases generate the
nil receiver warning, although the conditions of 'if', 'for' and
'while' statements are always false when the 'obj' is nil (because any
message sent to nil returns zero).
for(int i = 0; i < [obj intM]; i++)
{
long long j = [obj longlongM]; // no-warning (currently generates
the 'nil receiver' warning)
}
while([obj intM] != 0)
{
long long j = [obj longlongM]; // no-warning (currently generates
the 'nil receiver' warning)
}
if([obj intM] != 0)
{
long long j = [obj longlongM]; // no-warning (currently generates
the 'nil receiver' warning)
}
More information about the cfe-dev
mailing list