[libclang] Index implicit property references.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142355 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index d45830e..e8e37a3 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -4051,12 +4051,18 @@
   CXIdxLoc endLoc;
 } CXIdxEndContainerInfo;
 
+typedef enum {
+  CXIdxEntityRef_Direct = 1,
+  CXIdxEntityRef_ImplicitProperty = 2
+} CXIdxEntityRefKind;
+
 typedef struct {
   CXCursor cursor;
   CXIdxLoc loc;
   CXIdxEntity referencedEntity;
   CXIdxEntity parentEntity;
   CXIdxContainer container;
+  CXIdxEntityRefKind kind;
 } CXIdxEntityRefInfo;
 
 typedef struct {
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index fb83d20..5adffbd 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1920,6 +1920,11 @@
   printCXIndexEntity(info->parentEntity);
   printf(" | container: ");
   printCXIndexContainer(info->container);
+  printf(" | kind: ");
+  switch (info->kind) {
+  case CXIdxEntityRef_Direct: printf("direct"); break;
+  case CXIdxEntityRef_ImplicitProperty: printf("implicit prop"); break;
+  }
   printf("\n");
 }
 
diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp
index b2ffb99..769a1c7 100644
--- a/tools/libclang/IndexBody.cpp
+++ b/tools/libclang/IndexBody.cpp
@@ -69,6 +69,21 @@
       IndexCtx.handleReference(MD, E->getSelectorStartLoc(), 0, ParentDC, E);
     return true;
   }
+
+  bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
+    if (E->isImplicitProperty()) {
+      if (ObjCMethodDecl *MD = E->getImplicitPropertyGetter())
+        IndexCtx.handleReference(MD, E->getLocation(), 0, ParentDC, E,
+                                 CXIdxEntityRef_ImplicitProperty);
+      if (ObjCMethodDecl *MD = E->getImplicitPropertySetter())
+        IndexCtx.handleReference(MD, E->getLocation(), 0, ParentDC, E,
+                                 CXIdxEntityRef_ImplicitProperty);
+    } else {
+      IndexCtx.handleReference(E->getExplicitProperty(), E->getLocation(), 0,
+                               ParentDC, E);
+    }
+    return true;
+  }
 };
 
 } // anonymous namespace
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 8a41856..f295582 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -388,7 +388,8 @@
 void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
                                       const NamedDecl *Parent,
                                       const DeclContext *DC,
-                                      const Expr *E) {
+                                      const Expr *E,
+                                      CXIdxEntityRefKind Kind) {
   if (Loc.isInvalid())
     return;
   if (!CB.indexEntityReference)
@@ -402,7 +403,8 @@
                               getIndexLoc(Loc),
                               getIndexEntity(D),
                               getIndexEntity(Parent),
-                              getIndexContainerForDC(DC) };
+                              getIndexContainerForDC(DC),
+                              Kind };
   CB.indexEntityReference(ClientData, &Info);
 }
 
diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h
index 7105680..d69f1c8 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -132,7 +132,8 @@
   void handleReference(const NamedDecl *D, SourceLocation Loc,
                        const NamedDecl *Parent,
                        const DeclContext *DC,
-                       const Expr *E = 0);
+                       const Expr *E = 0,
+                       CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct);
   
   void invokeStartedTagTypeDefinition(const TagDecl *D);