[cfe-commits] r101792 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/FixIt/typo.m

Douglas Gregor dgregor at apple.com
Mon Apr 19 11:02:19 PDT 2010


Author: dgregor
Date: Mon Apr 19 13:02:19 2010
New Revision: 101792

URL: http://llvm.org/viewvc/llvm-project?rev=101792&view=rev
Log:
When searching for code-completion and typo-correction candidates,
look from an Objective-C class or category to its implementation, to
pick up synthesized ivars. Fixes a problem reported by David
Chisnall.

Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/test/FixIt/typo.m

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=101792&r1=101791&r2=101792&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Apr 19 13:02:19 2010
@@ -2279,6 +2279,14 @@
       LookupVisibleDecls(IFace->getSuperClass(), Result, QualifiedNameLookup,
                          true, Consumer, Visited);
     }
+    
+    // If there is an implementation, traverse it. We do this to find
+    // synthesized ivars.
+    if (IFace->getImplementation()) {
+      ShadowContextRAII Shadow(Visited);
+      LookupVisibleDecls(IFace->getImplementation(), Result, 
+                         QualifiedNameLookup, true, Consumer, Visited);
+    }
   } else if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Ctx)) {
     for (ObjCProtocolDecl::protocol_iterator I = Protocol->protocol_begin(),
            E = Protocol->protocol_end(); I != E; ++I) {
@@ -2293,6 +2301,13 @@
       LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, 
                          Visited);
     }
+    
+    // If there is an implementation, traverse it.
+    if (Category->getImplementation()) {
+      ShadowContextRAII Shadow(Visited);
+      LookupVisibleDecls(Category->getImplementation(), Result, 
+                         QualifiedNameLookup, true, Consumer, Visited);
+    }    
   }
 }
 

Modified: cfe/trunk/test/FixIt/typo.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo.m?rev=101792&r1=101791&r2=101792&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/typo.m (original)
+++ cfe/trunk/test/FixIt/typo.m Mon Apr 19 13:02:19 2010
@@ -103,3 +103,37 @@
 }
   
 @end
+
+ at interface Ivar
+ at end
+
+ at protocol Proto
+ at property (retain) id ivar;
+ at end
+
+ at interface User <Proto>
+- (void)method;
+ at end
+
+ at implementation User
+ at synthesize ivar;
+
+- (void)method {
+    [ivar method]; // Test that we don't correct 'ivar' to 'Ivar'
+}
+ at end
+
+ at interface User2
+ at end
+
+ at interface User2 (Cat) < Proto>
+- (void)method;
+ at end
+
+ at implementation User2 (Cat)
+ at synthesize ivar;
+
+- (void)method {
+    [ivar method]; // Test that we don't correct 'ivar' to 'Ivar'
+}
+ at end





More information about the cfe-commits mailing list