r305511 - [Completion] Code complete the members for a dependent type after a '::'
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 15 14:40:54 PDT 2017
Author: arphaman
Date: Thu Jun 15 16:40:54 2017
New Revision: 305511
URL: http://llvm.org/viewvc/llvm-project?rev=305511&view=rev
Log:
[Completion] Code complete the members for a dependent type after a '::'
This commit is a follow up to r302797 which added support for dependent
completions after the '.' and '->' operators. This commit adds support for
dependent completions after the '::' operator.
Differential Revision: https://reviews.llvm.org/D34173
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/member-access.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=305511&r1=305510&r2=305511&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Jun 15 16:40:54 2017
@@ -4542,8 +4542,10 @@ void Sema::CodeCompleteQualifiedId(Scope
bool EnteringContext) {
if (!SS.getScopeRep() || !CodeCompleter)
return;
-
- DeclContext *Ctx = computeDeclContext(SS, EnteringContext);
+
+ // Always pretend to enter a context to ensure that a dependent type
+ // resolves to a dependent record.
+ DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true);
if (!Ctx)
return;
@@ -4573,7 +4575,9 @@ void Sema::CodeCompleteQualifiedId(Scope
Results.ExitScope();
CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer);
+ LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer,
+ /*IncludeGlobalScope=*/true,
+ /*IncludeDependentBases=*/true);
HandleCodeCompleteResults(this, CodeCompleter,
Results.getCompletionContext(),
Modified: cfe/trunk/test/CodeCompletion/member-access.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=305511&r1=305510&r2=305511&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/member-access.cpp (original)
+++ cfe/trunk/test/CodeCompletion/member-access.cpp Thu Jun 15 16:40:54 2017
@@ -145,4 +145,22 @@ public:
// CHECK-CC6: o2 : [#BaseTemplate<T>#]o2
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:142:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
}
+
+ static void staticFn(T &obj);
+
+ struct Nested { };
};
+
+template<typename T>
+void dependentColonColonCompletion() {
+ Template<T>::staticFn();
+// CHECK-CC7: function : [#void#]function()
+// CHECK-CC7: Nested : Nested
+// CHECK-CC7: o1 : [#BaseTemplate<int>#]o1
+// CHECK-CC7: o2 : [#BaseTemplate<T>#]o2
+// CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>)
+// CHECK-CC7: Template : Template
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:156:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+ typename Template<T>::Nested m;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:164:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+}
More information about the cfe-commits
mailing list