[cfe-commits] r101810 - /cfe/trunk/lib/Sema/SemaExprObjC.cpp

Douglas Gregor dgregor at apple.com
Mon Apr 19 13:09:36 PDT 2010


Author: dgregor
Date: Mon Apr 19 15:09:36 2010
New Revision: 101810

URL: http://llvm.org/viewvc/llvm-project?rev=101810&view=rev
Log:
When normal name lookup to disambiguiate an Objective-C message send
fails to find anything,  perform ivar lookup and, if we find one,
consider this an instance message.

Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=101810&r1=101809&r2=101810&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Apr 19 15:09:36 2010
@@ -505,6 +505,16 @@
   
   switch (Result.getResultKind()) {
   case LookupResult::NotFound:
+    // Normal name lookup didn't find anything. If we're in an
+    // Objective-C method, look for ivars. If we find one, we're done!
+    // FIXME: This is a hack. Ivar lookup should be part of normal lookup.
+    if (ObjCMethodDecl *Method = getCurMethodDecl()) {
+      ObjCInterfaceDecl *ClassDeclared;
+      if (Method->getClassInterface()->lookupInstanceVariable(Name, 
+                                                              ClassDeclared))
+        return ObjCInstanceMessage;
+    }
+      
     // Break out; we'll perform typo correction below.
     break;
 





More information about the cfe-commits mailing list