From: Douglas Gregor Date: Thu, 14 Jan 2010 16:08:12 +0000 (+0000) Subject: Switch code-completion's ivar lookup over to LookupVisibleDecls, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80f4f4ce5a4c1416492ca6835cc85bb7e538ffc9;p=clang Switch code-completion's ivar lookup over to LookupVisibleDecls, eliminating yet one more ResultBuilder::MaybeAddResult caller. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93430 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 46b538520b..cf232d1f17 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -212,6 +212,7 @@ namespace { bool IsNamespaceOrAlias(NamedDecl *ND) const; bool IsType(NamedDecl *ND) const; bool IsMember(NamedDecl *ND) const; + bool IsObjCIvar(NamedDecl *ND) const; //@} }; } @@ -712,6 +713,12 @@ bool ResultBuilder::IsMember(NamedDecl *ND) const { isa(ND); } +/// \rief Determines whether the given declaration is an Objective-C +/// instance variable. +bool ResultBuilder::IsObjCIvar(NamedDecl *ND) const { + return isa(ND); +} + namespace { /// \brief Visible declaration consumer that adds a code-completion result /// for each visible declaration. @@ -2052,11 +2059,10 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *BaseE, Class = BaseType->getAs()->getDecl(); // Add all ivars from this class and its superclasses. - for (; Class; Class = Class->getSuperClass()) { - for (ObjCInterfaceDecl::ivar_iterator IVar = Class->ivar_begin(), - IVarEnd = Class->ivar_end(); - IVar != IVarEnd; ++IVar) - Results.MaybeAddResult(Result(*IVar, 0), CurContext); + if (Class) { + CodeCompletionDeclConsumer Consumer(Results, CurContext); + Results.setFilter(&ResultBuilder::IsObjCIvar); + LookupVisibleDecls(Class, LookupMemberName, Consumer); } }