Skip to content

Commit 163488f

Browse files
author
Fariborz Jahanian
committed
When dealing with an assignment with LHS being a property reference
expression, the entire assignment tree is rewritten into a property setter messaging. This includes rewriting the RHS. Do not attempt to rewrite RHS again. Never rewrite a rewritten text! Fixes //rdar: //8527018. llvm-svn: 116104
1 parent be40921 commit 163488f

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

clang/clang.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@
11021102
9012911C1048068D0083456D /* ASTUnit.cpp */,
11031103
1A2A54A50FD1DD1C00F4CE45 /* ASTConsumers.cpp */,
11041104
1A2A54A70FD1DD1C00F4CE45 /* CacheTokens.cpp */,
1105+
DE4DC7A20EA1C33E00069E5A /* TokenRewriter.cpp */,
11051106
1ACB57DB1105820D0047B991 /* CompilerInstance.cpp */,
11061107
1ACB57DC1105820D0047B991 /* CompilerInvocation.cpp */,
11071108
1ACB57DD1105820D0047B991 /* DeclXML.cpp */,
@@ -2006,7 +2007,6 @@
20062007
72D16C1E0D9975C400E6DA4A /* HTMLRewrite.cpp */,
20072008
DEF7D9F80C9C8B1D0001F598 /* Rewriter.cpp */,
20082009
DECAB0CF0DB3C84200E13CCB /* RewriteRope.cpp */,
2009-
DE4DC7A20EA1C33E00069E5A /* TokenRewriter.cpp */,
20102010
);
20112011
name = Rewrite;
20122012
sourceTree = "<group>";

clang/lib/Rewrite/RewriteObjC.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5363,6 +5363,15 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
53635363
newStmt = RewriteFunctionBodyOrGlobalInitializer(S);
53645364
if (newStmt)
53655365
*CI = newStmt;
5366+
// If dealing with an assignment with LHS being a property reference
5367+
// expression, the entire assignment tree is rewritten into a property
5368+
// setter messaging. This involvs the RHS too. Do not attempt to rewrite
5369+
// RHS again.
5370+
if (ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(S))
5371+
if (PropSetters[PRE]) {
5372+
++CI;
5373+
continue;
5374+
}
53665375
}
53675376

53685377
if (BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2+
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
3+
// rdar:// 8527018
4+
5+
void *sel_registerName(const char *);
6+
7+
@class NSString;
8+
@interface CoreDAVDiscoveryAccountInfo {
9+
NSString *_scheme;
10+
}
11+
@property (retain) NSString *scheme;
12+
- (void) Meth ;
13+
@end
14+
15+
@implementation CoreDAVDiscoveryAccountInfo
16+
@synthesize scheme=_scheme;
17+
- (void) Meth {
18+
CoreDAVDiscoveryAccountInfo *discoveryInfo;
19+
discoveryInfo.scheme = @"https";
20+
}
21+
@end

0 commit comments

Comments
 (0)