[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
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 2745ac9..564ac56 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -4031,7 +4031,8 @@
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 903bfc5..7d571a0 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1641,6 +1641,7 @@
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 b5da646..f597797 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -736,7 +736,12 @@
EntityInfo.kind = CXIdxEntity_CXXStaticVariable;
break;
case Decl::Field:
- EntityInfo.kind = CXIdxEntity_Field; break;
+ EntityInfo.kind = CXIdxEntity_Field;
+ if (const CXXRecordDecl *
+ CXXRec = dyn_cast<CXXRecordDecl>(D->getDeclContext()))
+ if (!CXXRec->isPOD())
+ EntityInfo.kind = CXIdxEntity_CXXInstanceVariable;
+ break;
case Decl::EnumConstant:
EntityInfo.kind = CXIdxEntity_EnumConstant; break;
case Decl::ObjCInterface: