[cfe-commits] r91138 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/templates.cpp
Douglas Gregor
dgregor at apple.com
Fri Dec 11 10:28:39 PST 2009
Author: dgregor
Date: Fri Dec 11 12:28:39 2009
New Revision: 91138
URL: http://llvm.org/viewvc/llvm-project?rev=91138&view=rev
Log:
Teach code completion to instantiate templates when it needs to
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/templates.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=91138&r1=91137&r2=91138&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Dec 11 12:28:39 2009
@@ -1740,7 +1740,12 @@
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);
Modified: cfe/trunk/test/CodeCompletion/templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/templates.cpp?rev=91138&r1=91137&r2=91138&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/templates.cpp (original)
+++ cfe/trunk/test/CodeCompletion/templates.cpp Fri Dec 11 12:28:39 2009
@@ -1,16 +1,28 @@
namespace std {
template<typename T>
- class allocator;
+ class allocator {
+ public:
+ void in_base();
+ };
- template<typename T, typename Alloc = std::allocator<T> > class vector;
+ template<typename T, typename Alloc = std::allocator<T> >
+ class vector : Alloc {
+ public:
+ void foo();
+ void stop();
+ };
template<typename Alloc> class vector<bool, Alloc>;
}
void f() {
- std::
- // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:8 %s -o - | FileCheck -check-prefix=CC1 %s
+ std::vector<int> 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
More information about the cfe-commits
mailing list