diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-09 21:44:02 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-09 21:44:02 +0000 |
commit | a3b23b025bdc75595279aaed1ca055a76fcde1d6 (patch) | |
tree | 32d7651a869983821452ee4c1552774398cecb9e /clang/lib/Sema/SemaLookup.cpp | |
parent | 073901c8365826d483257c1b422ed7548fabddfe (diff) | |
download | bcm5719-llvm-a3b23b025bdc75595279aaed1ca055a76fcde1d6.tar.gz bcm5719-llvm-a3b23b025bdc75595279aaed1ca055a76fcde1d6.zip |
Don't walk the translation unit context to produce protocol names when
global code completions are disabled (e.g., because they are
cached). Also, make sure that forward-declared protocols are visited
when we look for all visible names within a declaration context.
Previously, we would end up with duplicate completions for protocols.
llvm-svn: 121416
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 16ca78f4dd2..6ff9cc69f1c 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2463,12 +2463,24 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, for (DeclContext::decl_iterator D = CurCtx->decls_begin(), DEnd = CurCtx->decls_end(); D != DEnd; ++D) { - if (NamedDecl *ND = dyn_cast<NamedDecl>(*D)) + if (NamedDecl *ND = dyn_cast<NamedDecl>(*D)) { if (Result.isAcceptableDecl(ND)) { Consumer.FoundDecl(ND, Visited.checkHidden(ND), InBaseClass); Visited.add(ND); } - + } else if (ObjCForwardProtocolDecl *ForwardProto + = dyn_cast<ObjCForwardProtocolDecl>(*D)) { + for (ObjCForwardProtocolDecl::protocol_iterator + P = ForwardProto->protocol_begin(), + PEnd = ForwardProto->protocol_end(); + P != PEnd; + ++P) { + if (Result.isAcceptableDecl(*P)) { + Consumer.FoundDecl(*P, Visited.checkHidden(*P), InBaseClass); + Visited.add(*P); + } + } + } // Visit transparent contexts and inline namespaces inside this context. if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) { if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace()) |