From 41778c3fa9bfa446cf3782968161d88ff3a2c939 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 30 Jan 2013 06:58:39 +0000 Subject: The instance methods of the root class of an Objective-C hieararchy can be messaged via the metaclass. Provide code completions for this case. Fixes . llvm-svn: 173903 --- clang/lib/Sema/SemaCodeComplete.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaCodeComplete.cpp') diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index ce580ceea30..48d1b61cd3a 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4769,10 +4769,15 @@ static void AddObjCMethods(ObjCContainerDecl *Container, bool InOriginalClass = true) { typedef CodeCompletionResult Result; Container = getContainerDef(Container); + ObjCInterfaceDecl *IFace = dyn_cast(Container); + bool isRootClass = IFace && !IFace->getSuperClass(); for (ObjCContainerDecl::method_iterator M = Container->meth_begin(), MEnd = Container->meth_end(); M != MEnd; ++M) { - if (M->isInstanceMethod() == WantInstanceMethods) { + // The instance methods on the root class can be messaged via the + // metaclass. + if (M->isInstanceMethod() == WantInstanceMethods || + (isRootClass && !WantInstanceMethods)) { // Check whether the selector identifiers we've been given are a // subset of the identifiers for this particular method. if (!isAcceptableObjCMethod(*M, WantKind, SelIdents, NumSelIdents, @@ -4805,7 +4810,6 @@ static void AddObjCMethods(ObjCContainerDecl *Container, } } - ObjCInterfaceDecl *IFace = dyn_cast(Container); if (!IFace || !IFace->hasDefinition()) return; -- cgit v1.2.3