]> granicus.if.org Git - clang/commitdiff
Fixed a nasty bug which took a while to come up with a test case,
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 23 Jan 2008 20:34:40 +0000 (20:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 23 Jan 2008 20:34:40 +0000 (20:34 +0000)
diagnose, and took even longer to fix. It has to do with rewriting of a message
receiver which is an 'ivar' reference. Fix, however, is to remove a code which
was not doing the right thing and no longer needed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46279 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteTest.cpp
include/clang/AST/Expr.h
test/Sema/objc-ivar-receiver-1.m [new file with mode: 0644]

index eca9349fb689e33316c06bee5cca1864db9c9922..4a67be7f7392a5e3a56c048029825d00b583ff22 100644 (file)
@@ -705,6 +705,10 @@ Stmt *RewriteTest::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
     delete IV;
     return Replacement;
   } else {
+#if 0
+    /// This code is not right. It seems unnecessary. It breaks use of 
+    /// ivar reference used as 'receiver' of an expression; as in:
+    /// [newInv->_container addObject:0];
     if (CurMethodDecl) {
       if (const PointerType *pType = IV->getBase()->getType()->getAsPointerType()) {
         ObjCInterfaceType *intT = dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
@@ -729,6 +733,7 @@ Stmt *RewriteTest::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
         }
       }
     }
+#endif
     return IV;
   }
 }
index 3771c00281781d0e9ef84bd7365e951200c98ff5..4eb4072a8749a177200a4f3b3b17900378eb383a 100644 (file)
@@ -1389,6 +1389,7 @@ public:
   const ObjCIvarDecl *getDecl() const { return D; }
   virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
   Expr *const getBase() const { return Base; }
+  void setBase(Expr * base) { Base = base; }
   const bool isArrow() const { return IsArrow; }
   const bool isFreeIvar() const { return IsFreeIvar; }
   
diff --git a/test/Sema/objc-ivar-receiver-1.m b/test/Sema/objc-ivar-receiver-1.m
new file mode 100644 (file)
index 0000000..c7df178
--- /dev/null
@@ -0,0 +1,23 @@
+// RUN: clang -rewrite-test %s | clang
+// RUN: clang -rewrite-test %s | grep 'newInv->_container'
+
+@interface NSMutableArray 
+- (void)addObject:(id)addObject;
+@end
+
+@interface NSInvocation {
+@private
+    id _container;
+}
++ (NSInvocation *)invocationWithMethodSignature;
+
+@end
+
+@implementation NSInvocation
+
++ (NSInvocation *)invocationWithMethodSignature {
+    NSInvocation *newInv;
+    [newInv->_container addObject:0];
+   return 0;
+}
+@end