From 90fe4bc75d7fe0a68fd858b278221101787320da Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 8 Oct 2010 21:12:22 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116104 91177308-0d34-0410-b5e6-96231b3b80d8 --- clang.xcodeproj/project.pbxproj | 2 +- lib/Rewrite/RewriteObjC.cpp | 9 ++++++++ .../Rewriter/rewrite-property-set-cfstring.mm | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/Rewriter/rewrite-property-set-cfstring.mm diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index 2a25645088..9c95d0a3de 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -1102,6 +1102,7 @@ 9012911C1048068D0083456D /* ASTUnit.cpp */, 1A2A54A50FD1DD1C00F4CE45 /* ASTConsumers.cpp */, 1A2A54A70FD1DD1C00F4CE45 /* CacheTokens.cpp */, + DE4DC7A20EA1C33E00069E5A /* TokenRewriter.cpp */, 1ACB57DB1105820D0047B991 /* CompilerInstance.cpp */, 1ACB57DC1105820D0047B991 /* CompilerInvocation.cpp */, 1ACB57DD1105820D0047B991 /* DeclXML.cpp */, @@ -2006,7 +2007,6 @@ 72D16C1E0D9975C400E6DA4A /* HTMLRewrite.cpp */, DEF7D9F80C9C8B1D0001F598 /* Rewriter.cpp */, DECAB0CF0DB3C84200E13CCB /* RewriteRope.cpp */, - DE4DC7A20EA1C33E00069E5A /* TokenRewriter.cpp */, ); name = Rewrite; sourceTree = ""; diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index abd46df831..af756c52ef 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -5363,6 +5363,15 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { newStmt = RewriteFunctionBodyOrGlobalInitializer(S); if (newStmt) *CI = newStmt; + // If dealing with an assignment with LHS being a property reference + // expression, the entire assignment tree is rewritten into a property + // setter messaging. This involvs the RHS too. Do not attempt to rewrite + // RHS again. + if (ObjCPropertyRefExpr *PRE = dyn_cast(S)) + if (PropSetters[PRE]) { + ++CI; + continue; + } } if (BlockExpr *BE = dyn_cast(S)) { diff --git a/test/Rewriter/rewrite-property-set-cfstring.mm b/test/Rewriter/rewrite-property-set-cfstring.mm new file mode 100644 index 0000000000..5e670bf751 --- /dev/null +++ b/test/Rewriter/rewrite-property-set-cfstring.mm @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar:// 8527018 + +void *sel_registerName(const char *); + +@class NSString; +@interface CoreDAVDiscoveryAccountInfo { + NSString *_scheme; +} +@property (retain) NSString *scheme; +- (void) Meth ; +@end + +@implementation CoreDAVDiscoveryAccountInfo +@synthesize scheme=_scheme; +- (void) Meth { + CoreDAVDiscoveryAccountInfo *discoveryInfo; + discoveryInfo.scheme = @"https"; +} +@end -- 2.40.0