From da5f2d2360ace0ea32e4f3194906be4899a76c7d Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 5 Dec 2011 22:05:28 +0000 Subject: [PATCH] [libclang] When indexing a field in a C++ class, return an entity of kind CXIdxEntity_CXXInstanceVariable. rdar://10522503. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145859 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 3 ++- tools/c-index-test/c-index-test.c | 1 + tools/libclang/IndexingContext.cpp | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 2745ac9bd0..564ac56b7f 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -4031,7 +4031,8 @@ typedef enum { CXIdxEntity_CXXConstructor = 22, CXIdxEntity_CXXDestructor = 23, CXIdxEntity_CXXConversionFunction = 24, - CXIdxEntity_CXXTypeAlias = 25 + CXIdxEntity_CXXTypeAlias = 25, + CXIdxEntity_CXXInstanceVariable = 26 } CXIdxEntityKind; diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 903bfc59d8..7d571a0dbe 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -1641,6 +1641,7 @@ static const char *getEntityKindString(CXIdxEntityKind kind) { case CXIdxEntity_CXXNamespace: return "namespace"; case CXIdxEntity_CXXNamespaceAlias: return "namespace-alias"; case CXIdxEntity_CXXStaticVariable: return "c++-static-var"; + case CXIdxEntity_CXXInstanceVariable: return "c++-instance-var"; case CXIdxEntity_CXXStaticMethod: return "c++-static-method"; case CXIdxEntity_CXXInstanceMethod: return "c++-instance-method"; case CXIdxEntity_CXXConstructor: return "constructor"; diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index b5da6461bc..f597797132 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -736,7 +736,12 @@ void IndexingContext::getEntityInfo(const NamedDecl *D, EntityInfo.kind = CXIdxEntity_CXXStaticVariable; break; case Decl::Field: - EntityInfo.kind = CXIdxEntity_Field; break; + EntityInfo.kind = CXIdxEntity_Field; + if (const CXXRecordDecl * + CXXRec = dyn_cast(D->getDeclContext())) + if (!CXXRec->isPOD()) + EntityInfo.kind = CXIdxEntity_CXXInstanceVariable; + break; case Decl::EnumConstant: EntityInfo.kind = CXIdxEntity_EnumConstant; break; case Decl::ObjCInterface: -- 2.40.0