]> granicus.if.org Git - clang/commitdiff
When dealing with an assignment with LHS being a property reference
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 8 Oct 2010 21:12:22 +0000 (21:12 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 8 Oct 2010 21:12:22 +0000 (21:12 +0000)
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
lib/Rewrite/RewriteObjC.cpp
test/Rewriter/rewrite-property-set-cfstring.mm [new file with mode: 0644]

index 2a256450887b2e8161fdfa1d9101a31e9aac1d7a..9c95d0a3dee5c0ed6924daa5c0242b6448d219d0 100644 (file)
                                9012911C1048068D0083456D /* ASTUnit.cpp */,
                                1A2A54A50FD1DD1C00F4CE45 /* ASTConsumers.cpp */,
                                1A2A54A70FD1DD1C00F4CE45 /* CacheTokens.cpp */,
+                               DE4DC7A20EA1C33E00069E5A /* TokenRewriter.cpp */,
                                1ACB57DB1105820D0047B991 /* CompilerInstance.cpp */,
                                1ACB57DC1105820D0047B991 /* CompilerInvocation.cpp */,
                                1ACB57DD1105820D0047B991 /* DeclXML.cpp */,
                                72D16C1E0D9975C400E6DA4A /* HTMLRewrite.cpp */,
                                DEF7D9F80C9C8B1D0001F598 /* Rewriter.cpp */,
                                DECAB0CF0DB3C84200E13CCB /* RewriteRope.cpp */,
-                               DE4DC7A20EA1C33E00069E5A /* TokenRewriter.cpp */,
                        );
                        name = Rewrite;
                        sourceTree = "<group>";
index abd46df831cdeada1053160c8cda23371bfdcca3..af756c52ef633118b141ded20cc25c156ecad2d2 100644 (file)
@@ -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<ObjCPropertyRefExpr>(S))
+        if (PropSetters[PRE]) {
+          ++CI;
+          continue;
+        }
     }
 
   if (BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
diff --git a/test/Rewriter/rewrite-property-set-cfstring.mm b/test/Rewriter/rewrite-property-set-cfstring.mm
new file mode 100644 (file)
index 0000000..5e670bf
--- /dev/null
@@ -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