aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/IndexTypeSourceInfo.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-13 18:47:41 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-13 18:47:41 +0000
commite422e45a6a89d450b8eca10f671b49874e87617a (patch)
treebe55d8a6c74db604e5d83cb474c96ceeefe39274 /tools/libclang/IndexTypeSourceInfo.cpp
parentc2be04eaec94e20fc825fb98b713112d9d82562f (diff)
[libclang] Indexing API: Fix indexing of missed references.
rdar://10567864&10567916 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/IndexTypeSourceInfo.cpp')
-rw-r--r--tools/libclang/IndexTypeSourceInfo.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/tools/libclang/IndexTypeSourceInfo.cpp b/tools/libclang/IndexTypeSourceInfo.cpp
index 04ed329f3b..1b2069d30d 100644
--- a/tools/libclang/IndexTypeSourceInfo.cpp
+++ b/tools/libclang/IndexTypeSourceInfo.cpp
@@ -34,6 +34,11 @@ public:
return true;
}
+ bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+ IndexCtx.indexNestedNameSpecifierLoc(NNS, Parent, ParentDC);
+ return true;
+ }
+
bool VisitTagTypeLoc(TagTypeLoc TL) {
TagDecl *D = TL.getDecl();
if (D->getParentFunctionOrMethod())
@@ -75,17 +80,54 @@ void IndexingContext::indexTypeSourceInfo(TypeSourceInfo *TInfo,
if (!TInfo || TInfo->getTypeLoc().isNull())
return;
- if (DC == 0)
- DC = Parent->getDeclContext();
indexTypeLoc(TInfo->getTypeLoc(), Parent, DC);
}
void IndexingContext::indexTypeLoc(TypeLoc TL,
const NamedDecl *Parent,
const DeclContext *DC) {
+ if (TL.isNull())
+ return;
+
+ if (DC == 0)
+ DC = Parent->getLexicalDeclContext();
TypeIndexer(*this, Parent, DC).TraverseTypeLoc(TL);
}
+void IndexingContext::indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
+ const NamedDecl *Parent,
+ const DeclContext *DC) {
+ if (!NNS)
+ return;
+
+ if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
+ indexNestedNameSpecifierLoc(Prefix, Parent, DC);
+
+ if (DC == 0)
+ DC = Parent->getLexicalDeclContext();
+ SourceLocation Loc = NNS.getSourceRange().getBegin();
+
+ switch (NNS.getNestedNameSpecifier()->getKind()) {
+ case NestedNameSpecifier::Identifier:
+ case NestedNameSpecifier::Global:
+ break;
+
+ case NestedNameSpecifier::Namespace:
+ handleReference(NNS.getNestedNameSpecifier()->getAsNamespace(),
+ Loc, Parent, DC);
+ break;
+ case NestedNameSpecifier::NamespaceAlias:
+ handleReference(NNS.getNestedNameSpecifier()->getAsNamespaceAlias(),
+ Loc, Parent, DC);
+ break;
+
+ case NestedNameSpecifier::TypeSpec:
+ case NestedNameSpecifier::TypeSpecWithTemplate:
+ indexTypeLoc(NNS.getTypeLoc(), Parent, DC);
+ break;
+ }
+}
+
void IndexingContext::indexTagDecl(const TagDecl *D) {
if (handleTagDecl(D)) {
if (D->isThisDeclarationADefinition())