[arcmt] Make sure the function has an associated parameter for the argument

before checking for its attributes.

rdar://13192395

llvm-svn: 175184
This commit is contained in:
Argyrios Kyrtzidis 2013-02-14 17:29:16 +00:00
parent f940fd05bd
commit d07fabf034
2 changed files with 10 additions and 1 deletions

View File

@ -430,7 +430,7 @@ private:
if (arg == E || arg->IgnoreParenImpCasts() == E)
break;
}
if (i < callE->getNumArgs()) {
if (i < callE->getNumArgs() && i < FD->getNumParams()) {
ParmVarDecl *PD = FD->getParamDecl(i);
if (PD->getAttr<CFConsumedAttr>()) {
isConsumed = true;

View File

@ -54,3 +54,12 @@ CFStringRef f3() {
return (CFStringRef)[[[NSString alloc] init] autorelease]; // expected-error {{it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object}} \
// expected-note {{remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased}}
}
extern void NSLog(NSString *format, ...);
// rdar://13192395
void f4(NSString *s) {
NSLog(@"%@", (CFStringRef)s); // expected-error {{cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
// expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
}