[cfe-commits] r46279 - in /cfe/trunk: Driver/RewriteTest.cpp include/clang/AST/Expr.h test/Sema/objc-ivar-receiver-1.m

Fariborz Jahanian fjahanian at apple.com
Wed Jan 23 12:34:40 PST 2008


Author: fjahanian
Date: Wed Jan 23 14:34:40 2008
New Revision: 46279

URL: http://llvm.org/viewvc/llvm-project?rev=46279&view=rev
Log:
Fixed a nasty bug which took a while to come up with a test case, 
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.

Added:
    cfe/trunk/test/Sema/objc-ivar-receiver-1.m
Modified:
    cfe/trunk/Driver/RewriteTest.cpp
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=46279&r1=46278&r2=46279&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Jan 23 14:34:40 2008
@@ -705,6 +705,10 @@
     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 @@
         }
       }
     }
+#endif
     return IV;
   }
 }

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=46279&r1=46278&r2=46279&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Jan 23 14:34:40 2008
@@ -1389,6 +1389,7 @@
   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; }
   

Added: cfe/trunk/test/Sema/objc-ivar-receiver-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-ivar-receiver-1.m?rev=46279&view=auto

==============================================================================
--- cfe/trunk/test/Sema/objc-ivar-receiver-1.m (added)
+++ cfe/trunk/test/Sema/objc-ivar-receiver-1.m Wed Jan 23 14:34:40 2008
@@ -0,0 +1,23 @@
+// RUN: clang -rewrite-test %s | clang
+// RUN: clang -rewrite-test %s | grep 'newInv->_container'
+
+ at interface NSMutableArray 
+- (void)addObject:(id)addObject;
+ at end
+
+ at interface NSInvocation {
+ at private
+    id _container;
+}
++ (NSInvocation *)invocationWithMethodSignature;
+
+ at end
+
+ at implementation NSInvocation
+
++ (NSInvocation *)invocationWithMethodSignature {
+    NSInvocation *newInv;
+    [newInv->_container addObject:0];
+   return 0;
+}
+ at end





More information about the cfe-commits mailing list