aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-18 15:50:50 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-18 15:50:50 +0000
commitaca19be8731fc31cff68702de0dc7f30ce908979 (patch)
treea855dddb91eca1455fe966640dda8faa28bf437a
parentc0f5b754eacfd0d1cb5338e048850e5d29ca42f7 (diff)
[libclang] Index implicit property references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142355 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang-c/Index.h6
-rw-r--r--tools/c-index-test/c-index-test.c5
-rw-r--r--tools/libclang/IndexBody.cpp15
-rw-r--r--tools/libclang/IndexingContext.cpp6
-rw-r--r--tools/libclang/IndexingContext.h3
5 files changed, 32 insertions, 3 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index d45830ef91..e8e37a3d0b 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -4051,12 +4051,18 @@ typedef struct {
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 fb83d20cbe..5adffbd2a8 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1920,6 +1920,11 @@ static void index_indexEntityReference(CXClientData client_data,
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 b2ffb99267..769a1c7ae8 100644
--- a/tools/libclang/IndexBody.cpp
+++ b/tools/libclang/IndexBody.cpp
@@ -69,6 +69,21 @@ public:
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 8a41856032..f295582b53 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -388,7 +388,8 @@ void IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
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 @@ void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
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 710568058f..d69f1c8eaa 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -132,7 +132,8 @@ public:
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);