[cfe-commits] r86591 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/code-completion.cpp tools/CIndex/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Mon Nov 9 13:35:27 PST 2009
Author: dgregor
Date: Mon Nov 9 15:35:27 2009
New Revision: 86591
URL: http://llvm.org/viewvc/llvm-project?rev=86591&view=rev
Log:
Make sure that we look into nested, transparent declaration contexts
when looking for a name within a given DeclContext. Now enumerators
will show up in code-completion results.
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/code-completion.cpp
cfe/trunk/tools/CIndex/CIndex.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=86591&r1=86590&r2=86591&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Nov 9 15:35:27 2009
@@ -473,17 +473,24 @@
for (DeclContext *CurCtx = Ctx->getPrimaryContext(); CurCtx;
CurCtx = CurCtx->getNextContext()) {
for (DeclContext::decl_iterator D = CurCtx->decls_begin(),
- DEnd = CurCtx->decls_end();
+ DEnd = CurCtx->decls_end();
D != DEnd; ++D) {
if (NamedDecl *ND = dyn_cast<NamedDecl>(*D))
Results.MaybeAddResult(Result(ND, Rank, 0, InBaseClass), CurContext);
+
+ // Visit transparent contexts inside this context.
+ if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) {
+ if (InnerCtx->isTransparentContext())
+ CollectMemberLookupResults(InnerCtx, Rank, CurContext, Visited,
+ Results, InBaseClass);
+ }
}
}
// Traverse the contexts of inherited classes.
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Ctx)) {
for (CXXRecordDecl::base_class_iterator B = Record->bases_begin(),
- BEnd = Record->bases_end();
+ BEnd = Record->bases_end();
B != BEnd; ++B) {
QualType BaseType = B->getType();
Modified: cfe/trunk/test/Index/code-completion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/code-completion.cpp?rev=86591&r1=86590&r2=86591&view=diff
==============================================================================
--- cfe/trunk/test/Index/code-completion.cpp (original)
+++ cfe/trunk/test/Index/code-completion.cpp Mon Nov 9 15:35:27 2009
@@ -2,6 +2,8 @@
#include "nonexistent_header.h"
struct X {
int member;
+
+ enum E { Val1 };
};
struct Y {
@@ -17,7 +19,7 @@
struct Z get_Z();
void test_Z() {
- // RUN: c-index-test -code-completion-at=%s:21:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
+ // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
get_Z().member = 17;
}
@@ -27,12 +29,14 @@
int& overloaded(Z z, int second);
void test_overloaded() {
- // RUN: c-index-test -code-completion-at=%s:31:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
+ // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
overloaded(Z(), 0);
}
+// CHECK-MEMBER: EnumDecl:{Informative X::}{TypedText E}
// CHECK-MEMBER: FieldDecl:{TypedText member}
// CHECK-MEMBER: FunctionDecl:{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
+// CHECK-MEMBER: EnumConstantDecl:{Informative E::}{TypedText Val1}
// CHECK-MEMBER: FunctionDecl:{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
// CHECK-MEMBER: FunctionDecl:{TypedText operator int}{LeftParen (}{RightParen )}
// CHECK-MEMBER: FunctionDecl:{TypedText operator=}{LeftParen (}{Placeholder struct Z const &}{RightParen )}
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=86591&r1=86590&r2=86591&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Mon Nov 9 15:35:27 2009
@@ -1141,6 +1141,7 @@
.Case("Struct", CXCursor_StructDecl)
.Case("Union", CXCursor_UnionDecl)
.Case("Class", CXCursor_ClassDecl)
+ .Case("Enum", CXCursor_EnumDecl)
.Case("Field", CXCursor_FieldDecl)
.Case("EnumConstant", CXCursor_EnumConstantDecl)
.Case("Function", CXCursor_FunctionDecl)
More information about the cfe-commits
mailing list