Author: snaroff
Date: Tue Feb 17 09:05:38 2009
New Revision: 64764

URL: http://llvm.org/viewvc/llvm-project?rev=64764&view=rev
Log:
Fix <rdar://problem/6557148> clang ObjC rewriter: Crash rewriting attached test 
case (properties?).

RewriteObjC::SynthMessageExpr() should *not* null out the arguments in the 
original message expression (since we will need them in 
RewritePropertySetter()).

Modified:
    cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
    cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/properties.m

Modified: 
cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=64764&r1=64763&r2=64764&view=diff

==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp 
(original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Tue 
Feb 17 09:05:38 2009
@@ -2430,9 +2430,10 @@
       }
     } 
     MsgExprs.push_back(userExpr);
-    // We've transferred the ownership to MsgExprs. Null out the argument in
-    // the original expression, since we will delete it below.
-    Exp->setArg(i, 0);
+    // We've transferred the ownership to MsgExprs. For now, we *don't* null
+    // out the argument in the original expression (since we aren't deleting
+    // the ObjCMessageExpr). See RewritePropertySetter() usage for more info.
+    //Exp->setArg(i, 0);
   }
   // Generate the funky cast.
   CastExpr *cast;
@@ -2543,13 +2544,13 @@
       new ConditionalOperator(lessThanExpr, CE, STCE, returnType);
     ReplacingStmt = new ParenExpr(SourceLocation(), SourceLocation(), 
CondExpr);
   }
+  // delete Exp; leak for now, see RewritePropertySetter() usage for more 
info. 
   return ReplacingStmt;
 }
 
 Stmt *RewriteObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) {
   Stmt *ReplacingStmt = SynthMessageExpr(Exp);
   
-  //ReplacingStmt->dump();
   // Now do the actual rewrite.
   ReplaceStmt(Exp, ReplacingStmt);
   

Modified: 
cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/properties.m?rev=64764&r1=64763&r2=64764&view=diff

==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/properties.m 
(original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/test/Rewriter/properties.m 
Tue Feb 17 09:05:38 2009
@@ -52,3 +52,24 @@
     obj1.o.i = 77;
 }
 @end
+
+...@class NSString;
+...@interface NSCoder
+- (float)decodeFloatForKey:(NSString *)key;
+- (float)decodeFloat;
+...@end
+...@interface Window {
+    float thickness;
+}
+...@property float thickness;
+...@end
+...@implementation Window
+...@synthesize thickness;
+
+- (id)initWithCoder:(NSCoder *)coder
+{
+  self.thickness = [coder decodeFloat];
+  self.thickness = [coder decodeFloatForKey:@"thickness"];
+}
+
+...@end


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to