]> granicus.if.org Git - clang/commitdiff
When normal name lookup to disambiguiate an Objective-C message send
authorDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 20:09:36 +0000 (20:09 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 20:09:36 +0000 (20:09 +0000)
fails to find anything,  perform ivar lookup and, if we find one,
consider this an instance message.

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

lib/Sema/SemaExprObjC.cpp

index c0e04fd6d40c8caae413bf47335b48d19d9d4677..ad95f00d246939e57d1f3b7631d6670f5b693f93 100644 (file)
@@ -505,6 +505,16 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S,
   
   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;