Skip to content

Commit 9c07e17

Browse files
author
Fariborz Jahanian
committed
Rewrite bug fix rewriting a property assignment when
its RHS is an ivar. Fixes //rdar: //8541517. llvm-svn: 116539
1 parent 89efff3 commit 9c07e17

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

clang/lib/Rewrite/RewriteObjC.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,6 +5479,12 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
54795479
// ^(NSURL *errorURL, NSError *error) { return (BOOL)1; };
54805480
SourceRange SrcRange = BinOp->getSourceRange();
54815481
Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(BinOp->getRHS());
5482+
// Need to rewrite the ivar access expression if need be.
5483+
if (isa<ObjCIvarRefExpr>(newStmt)) {
5484+
bool replaced = false;
5485+
newStmt = RewriteObjCNestedIvarRefExpr(newStmt, replaced);
5486+
}
5487+
54825488
DisableReplaceStmt = false;
54835489
//
54845490
// Unlike the main iterator, we explicily avoid changing 'BinOp'. If

clang/test/Rewriter/property-dot-syntax.mm

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,21 @@ - (void)METHOD {
2626
}
2727
@end
2828

29+
//rdar: // 8541517
30+
@interface A { }
31+
@property (retain) NSString *scheme;
32+
@end
33+
34+
@interface B : A {
35+
NSString* _schemeName;
36+
}
37+
@end
38+
39+
40+
@implementation B
41+
-(void) test {
42+
B *b;
43+
b.scheme = _schemeName; // error because of this line
44+
}
45+
@end
46+

0 commit comments

Comments
 (0)