summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-09 21:44:02 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-09 21:44:02 +0000
commita3b23b025bdc75595279aaed1ca055a76fcde1d6 (patch)
tree32d7651a869983821452ee4c1552774398cecb9e /clang/lib/Sema/SemaCodeComplete.cpp
parent073901c8365826d483257c1b422ed7548fabddfe (diff)
downloadbcm5719-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/SemaCodeComplete.cpp')
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 6d40fb8d295..727dd7929c0 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -4950,20 +4950,25 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
unsigned NumProtocols) {
ResultBuilder Results(*this, CodeCompletionContext::CCC_ObjCProtocolName);
- Results.EnterNewScope();
- // Tell the result set to ignore all of the protocols we have
- // already seen.
- for (unsigned I = 0; I != NumProtocols; ++I)
- if (ObjCProtocolDecl *Protocol = LookupProtocol(Protocols[I].first,
- Protocols[I].second))
- Results.Ignore(Protocol);
-
- // Add all protocols.
- AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, false,
- Results);
+ if (CodeCompleter && CodeCompleter->includeGlobals()) {
+ Results.EnterNewScope();
+
+ // Tell the result set to ignore all of the protocols we have
+ // already seen.
+ // FIXME: This doesn't work when caching code-completion results.
+ for (unsigned I = 0; I != NumProtocols; ++I)
+ if (ObjCProtocolDecl *Protocol = LookupProtocol(Protocols[I].first,
+ Protocols[I].second))
+ Results.Ignore(Protocol);
+
+ // Add all protocols.
+ AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, false,
+ Results);
- Results.ExitScope();
+ Results.ExitScope();
+ }
+
HandleCodeCompleteResults(this, CodeCompleter,
CodeCompletionContext::CCC_ObjCProtocolName,
Results.data(),Results.size());
@@ -4971,13 +4976,17 @@ void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
void Sema::CodeCompleteObjCProtocolDecl(Scope *) {
ResultBuilder Results(*this, CodeCompletionContext::CCC_ObjCProtocolName);
- Results.EnterNewScope();
- // Add all protocols.
- AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, true,
- Results);
+ if (CodeCompleter && CodeCompleter->includeGlobals()) {
+ Results.EnterNewScope();
+
+ // Add all protocols.
+ AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, true,
+ Results);
- Results.ExitScope();
+ Results.ExitScope();
+ }
+
HandleCodeCompleteResults(this, CodeCompleter,
CodeCompletionContext::CCC_ObjCProtocolName,
Results.data(),Results.size());
OpenPOWER on IntegriCloud