[libclang] Indexing API: fully index using decls and directives.

llvm-svn: 150268
This commit is contained in:
Argyrios Kyrtzidis 2012-02-10 20:10:48 +00:00
parent e5dc5b31f2
commit 4701cf61d7
2 changed files with 39 additions and 0 deletions

View File

@ -34,6 +34,16 @@ void foo2(S &s) {
s(3);
}
namespace NS {
namespace Inn {}
typedef int Foo;
}
using namespace NS;
using namespace NS::Inn;
using NS::Foo;
// RUN: c-index-test -index-file %s | FileCheck %s
// CHECK: [indexDeclaration]: kind: namespace | name: NS
// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
@ -58,3 +68,9 @@ void foo2(S &s) {
// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator=
// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator!=
// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator()
// CHECK: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 42:17
// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 43:17
// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: Inn | {{.*}} | loc: 43:21
// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 44:7
// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: Foo | {{.*}} | loc: 44:11

View File

@ -213,6 +213,29 @@ public:
return true;
}
bool VisitUsingDecl(UsingDecl *D) {
// FIXME: Parent for the following is CXIdxEntity_Unexposed with no USR,
// we should do better.
IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D);
for (UsingDecl::shadow_iterator
I = D->shadow_begin(), E = D->shadow_end(); I != E; ++I) {
IndexCtx.handleReference((*I)->getUnderlyingDecl(), D->getLocation(),
D, D->getLexicalDeclContext());
}
return true;
}
bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
// FIXME: Parent for the following is CXIdxEntity_Unexposed with no USR,
// we should do better.
IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D);
IndexCtx.handleReference(D->getNominatedNamespaceAsWritten(),
D->getLocation(), D, D->getLexicalDeclContext());
return true;
}
bool VisitClassTemplateDecl(ClassTemplateDecl *D) {
IndexCtx.handleClassTemplate(D);
if (D->isThisDeclarationADefinition())