r175184 - [arcmt] Make sure the function has an associated parameter for the argument
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Feb 14 09:29:16 PST 2013
Author: akirtzidis
Date: Thu Feb 14 11:29:16 2013
New Revision: 175184
URL: http://llvm.org/viewvc/llvm-project?rev=175184&view=rev
Log:
[arcmt] Make sure the function has an associated parameter for the argument
before checking for its attributes.
rdar://13192395
Modified:
cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp
cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m
Modified: cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp?rev=175184&r1=175183&r2=175184&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp Thu Feb 14 11:29:16 2013
@@ -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;
Modified: cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m?rev=175184&r1=175183&r2=175184&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m (original)
+++ cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m Thu Feb 14 11:29:16 2013
@@ -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 *')}}
+}
More information about the cfe-commits
mailing list