From: Douglas Gregor Date: Fri, 11 Dec 2009 18:28:39 +0000 (+0000) Subject: Teach code completion to instantiate templates when it needs to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1cd31aeb806077340be94e32429f3192cf139b0;p=clang Teach code completion to instantiate templates when it needs to git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91138 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index cfede40aac..f186165551 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -1740,7 +1740,12 @@ void Sema::CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS, DeclContext *Ctx = computeDeclContext(SS, EnteringContext); if (!Ctx) return; - + + // Try to instantiate any non-dependent declaration contexts before + // we look in them. + if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS)) + return; + ResultBuilder Results(*this); unsigned NextRank = CollectMemberLookupResults(Ctx, 0, Ctx, Results); diff --git a/test/CodeCompletion/templates.cpp b/test/CodeCompletion/templates.cpp index 5a0bdb19f1..ff5611823d 100644 --- a/test/CodeCompletion/templates.cpp +++ b/test/CodeCompletion/templates.cpp @@ -1,16 +1,28 @@ namespace std { template - class allocator; + class allocator { + public: + void in_base(); + }; - template > class vector; + template > + class vector : Alloc { + public: + void foo(); + void stop(); + }; template class vector; } void f() { - std:: - // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:8 %s -o - | FileCheck -check-prefix=CC1 %s + std::vector v; + v.foo(); + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:18:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: allocator<<#typename T#>> // CHECK-CC1-NEXT: vector<<#typename T#>{#, <#typename Alloc#>#}> - + // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s + // CHECK-CC2: foo + // CHECK-CC2: in_base + // CHECK-CC2: stop