r188101 - [arcmt] When handling unbridged casts, handle the body of BlockDecl separately because ParentMap does not record
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Aug 9 13:20:25 PDT 2013
Author: akirtzidis
Date: Fri Aug 9 15:20:25 2013
New Revision: 188101
URL: http://llvm.org/viewvc/llvm-project?rev=188101&view=rev
Log:
[arcmt] When handling unbridged casts, handle the body of BlockDecl separately because ParentMap does not record
Stmt parent nodes inside a BlockDecl.
Fixes rdar://14686900
Modified:
cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp
cfe/trunk/test/ARCMT/checking.m
Modified: cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp?rev=188101&r1=188100&r2=188101&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp Fri Aug 9 15:20:25 2013
@@ -77,6 +77,13 @@ public:
TraverseStmt(body);
}
+ bool TraverseBlockDecl(BlockDecl *D) {
+ // ParentMap does not enter into a BlockDecl to record its stmts, so use a
+ // new UnbridgedCastRewriter to handle the block.
+ UnbridgedCastRewriter(Pass).transformBody(D->getBody(), D);
+ return true;
+ }
+
bool VisitCastExpr(CastExpr *E) {
if (E->getCastKind() != CK_CPointerToObjCPointerCast &&
E->getCastKind() != CK_BitCast &&
Modified: cfe/trunk/test/ARCMT/checking.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=188101&r1=188100&r2=188101&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/checking.m (original)
+++ cfe/trunk/test/ARCMT/checking.m Fri Aug 9 15:20:25 2013
@@ -333,7 +333,9 @@ void rdar9504750(id p) {
}
@end
- at interface Test10 : NSObject
+ at interface Test10 : NSObject {
+ CFStringRef cfstr;
+}
@property (retain) id prop;
-(void)foo;
@end
@@ -342,3 +344,13 @@ void test(Test10 *x) {
x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \
// expected-note {{retained by the captured object}}
}
+
+ at implementation Test10
+-(void)foo {
+ ^{
+ NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
+ // expected-note {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
+ };
+}
+ at end
More information about the cfe-commits
mailing list