summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2019-02-21 11:22:58 +0000
committerEric Liu <ioeric@google.com>2019-02-21 11:22:58 +0000
commit206740e75679f45525fdb742bfa60fe7c3e6c094 (patch)
tree719c5295f8c9214896df5e45a70e3352a6822ef7 /clang/lib/Sema/SemaCodeComplete.cpp
parent7a183a86beb4e5e5f310a6853211009f3d432e57 (diff)
downloadbcm5719-llvm-206740e75679f45525fdb742bfa60fe7c3e6c094.tar.gz
bcm5719-llvm-206740e75679f45525fdb742bfa60fe7c3e6c094.zip
[CodeComplete] Collect visited contexts when scope specifier is invalid.
Summary: This will allow completion consumers to guess the specified scope by putting together scopes in the context with the specified scope (e.g. when the specified namespace is not imported yet). Reviewers: ilya-biryukov Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58446 llvm-svn: 354570
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index a042abb6f5f..cebf97a09ab 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -5061,7 +5061,20 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
if (SS.isInvalid()) {
CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol);
CC.setCXXScopeSpecifier(SS);
- HandleCodeCompleteResults(this, CodeCompleter, CC, nullptr, 0);
+ // As SS is invalid, we try to collect accessible contexts from the current
+ // scope with a dummy lookup so that the completion consumer can try to
+ // guess what the specified scope is.
+ ResultBuilder DummyResults(*this, CodeCompleter->getAllocator(),
+ CodeCompleter->getCodeCompletionTUInfo(), CC);
+ if (S->getEntity()) {
+ CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
+ BaseType);
+ LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ /*IncludeGlobalScope=*/false,
+ /*LoadExternal=*/false);
+ }
+ HandleCodeCompleteResults(this, CodeCompleter,
+ DummyResults.getCompletionContext(), nullptr, 0);
return;
}
// Always pretend to enter a context to ensure that a dependent type
OpenPOWER on IntegriCloud