]> granicus.if.org Git - clang/commitdiff
When searching for code-completion and typo-correction candidates,
authorDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 18:02:19 +0000 (18:02 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 18:02:19 +0000 (18:02 +0000)
look from an Objective-C class or category to its implementation, to
pick up synthesized ivars. Fixes a problem reported by David
Chisnall.

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

lib/Sema/SemaLookup.cpp
test/FixIt/typo.m

index 29b25a5dc3e36ce7724039bde93535749cf71501..abc0ed381e07cac6f162698b671cfe32e0196c5f 100644 (file)
@@ -2279,6 +2279,14 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result,
       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 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result,
       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);
+    }    
   }
 }
 
index fa0918a1e662f269580f212eddefccf053855d6b..00eb642a183a3b897fe46ad3e2723e88a77499e6 100644 (file)
@@ -103,3 +103,37 @@ void test2(Collide *a) {
 }
   
 @end
+
+@interface Ivar
+@end
+
+@protocol Proto
+@property (retain) id ivar;
+@end
+
+@interface User <Proto>
+- (void)method;
+@end
+
+@implementation User
+@synthesize ivar;
+
+- (void)method {
+    [ivar method]; // Test that we don't correct 'ivar' to 'Ivar'
+}
+@end
+
+@interface User2
+@end
+
+@interface User2 (Cat) < Proto>
+- (void)method;
+@end
+
+@implementation User2 (Cat)
+@synthesize ivar;
+
+- (void)method {
+    [ivar method]; // Test that we don't correct 'ivar' to 'Ivar'
+}
+@end