From 68478b0cc1ff03c0d13ceca6800c5becf08791e7 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 7 Dec 2011 05:52:06 +0000 Subject: [PATCH] [libclang] Index C++ namespaces. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146019 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/IndexDecl.cpp | 6 ++++++ tools/libclang/IndexingContext.cpp | 7 +++++++ tools/libclang/IndexingContext.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp index 0970054575..84c1134501 100644 --- a/tools/libclang/IndexDecl.cpp +++ b/tools/libclang/IndexDecl.cpp @@ -189,6 +189,12 @@ public: return true; } + bool VisitNamespaceDecl(NamespaceDecl *D) { + IndexCtx.handleNamespace(D); + IndexCtx.indexDeclContext(D); + return true; + } + bool VisitClassTemplateDecl(ClassTemplateDecl *D) { IndexCtx.handleClassTemplate(D); if (D->isThisDeclarationADefinition()) diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index f597797132..3f934be8a0 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -401,6 +401,13 @@ bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) { return handleDecl(D, D->getLocation(), getCursor(D), DInfo); } +bool IndexingContext::handleNamespace(const NamespaceDecl *D) { + DeclInfo DInfo(/*isRedeclaration=*/!D->isOriginalNamespace(), + /*isDefinition=*/true, + /*isContainer=*/true); + return handleDecl(D, D->getLocation(), getCursor(D), DInfo); +} + bool IndexingContext::handleClassTemplate(const ClassTemplateDecl *D) { return handleCXXRecordDecl(D->getTemplatedDecl(), D); } diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h index 6f33e194fd..a8a8edb362 100644 --- a/tools/libclang/IndexingContext.h +++ b/tools/libclang/IndexingContext.h @@ -370,6 +370,8 @@ public: bool handleObjCProperty(const ObjCPropertyDecl *D); + bool handleNamespace(const NamespaceDecl *D); + bool handleClassTemplate(const ClassTemplateDecl *D); bool handleFunctionTemplate(const FunctionTemplateDecl *D); bool handleTypeAliasTemplate(const TypeAliasTemplateDecl *D); -- 2.40.0