summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-28 17:50:33 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-28 17:50:33 +0000
commit792db266f3d2f12a7a16bf37d90074f54bca1e6f (patch)
treedc0c02223c305d3364c0eb213ebc1b11127f843f /tools
parentd7c15a64ba8ebdca0dd48dd1d2f233107d34494e (diff)
[libclang] When indexing an objc property, also provide information about
the getter/setter objc method entities that the property is associated with. rdar://10244558 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/c-index-test/c-index-test.c12
-rw-r--r--tools/libclang/Indexing.cpp12
-rw-r--r--tools/libclang/IndexingContext.cpp22
-rw-r--r--tools/libclang/IndexingContext.h16
-rw-r--r--tools/libclang/libclang.exports1
5 files changed, 61 insertions, 2 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index eee7f46ee4..925f56a601 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1809,6 +1809,7 @@ static void index_indexDeclaration(CXClientData client_data,
const CXIdxObjCCategoryDeclInfo *CatInfo;
const CXIdxObjCInterfaceDeclInfo *InterInfo;
const CXIdxObjCProtocolRefListInfo *ProtoInfo;
+ const CXIdxObjCPropertyDeclInfo *PropInfo;
const CXIdxCXXClassDeclInfo *CXXClassInfo;
unsigned i;
index_data = (IndexData *)client_data;
@@ -1870,6 +1871,17 @@ static void index_indexDeclaration(CXClientData client_data,
printProtocolList(ProtoInfo, client_data);
}
+ if ((PropInfo = clang_index_getObjCPropertyDeclInfo(info))) {
+ if (PropInfo->getter) {
+ printEntityInfo(" <getter>", client_data, PropInfo->getter);
+ printf("\n");
+ }
+ if (PropInfo->setter) {
+ printEntityInfo(" <setter>", client_data, PropInfo->setter);
+ printf("\n");
+ }
+ }
+
if ((CXXClassInfo = clang_index_getCXXClassDeclInfo(info))) {
for (i = 0; i != CXXClassInfo->numBases; ++i) {
printBaseClassInfo(client_data, CXXClassInfo->bases[i]);
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 1aed5313b7..1475859e33 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -608,6 +608,18 @@ clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *DInfo) {
return 0;
}
+const CXIdxObjCPropertyDeclInfo *
+clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *DInfo) {
+ if (!DInfo)
+ return 0;
+
+ const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
+ if (const ObjCPropertyDeclInfo *PropInfo = dyn_cast<ObjCPropertyDeclInfo>(DI))
+ return &PropInfo->ObjCPropDeclInfo;
+
+ return 0;
+}
+
const CXIdxIBOutletCollectionAttrInfo *
clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *AInfo) {
if (!AInfo)
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 2963f3b945..6797cc244a 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -517,8 +517,26 @@ bool IndexingContext::handleSynthesizedObjCMethod(const ObjCMethodDecl *D,
}
bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
- DeclInfo DInfo(/*isRedeclaration=*/false, /*isDefinition=*/false,
- /*isContainer=*/false);
+ ObjCPropertyDeclInfo DInfo;
+ EntityInfo GetterEntity;
+ EntityInfo SetterEntity;
+ ScratchAlloc SA(*this);
+
+ DInfo.ObjCPropDeclInfo.declInfo = &DInfo;
+
+ if (ObjCMethodDecl *Getter = D->getGetterMethodDecl()) {
+ getEntityInfo(Getter, GetterEntity, SA);
+ DInfo.ObjCPropDeclInfo.getter = &GetterEntity;
+ } else {
+ DInfo.ObjCPropDeclInfo.getter = 0;
+ }
+ if (ObjCMethodDecl *Setter = D->getSetterMethodDecl()) {
+ getEntityInfo(Setter, SetterEntity, SA);
+ DInfo.ObjCPropDeclInfo.setter = &SetterEntity;
+ } else {
+ DInfo.ObjCPropDeclInfo.setter = 0;
+ }
+
return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
}
diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h
index ea457052b4..8463e3fedf 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -53,6 +53,8 @@ struct DeclInfo : public CXIdxDeclInfo {
Info_ObjCProtocol,
Info_ObjCCategory,
+ Info_ObjCProperty,
+
Info_CXXClass
};
@@ -168,6 +170,20 @@ struct ObjCCategoryDeclInfo : public ObjCContainerDeclInfo {
static bool classof(const ObjCCategoryDeclInfo *D) { return true; }
};
+struct ObjCPropertyDeclInfo : public DeclInfo {
+ CXIdxObjCPropertyDeclInfo ObjCPropDeclInfo;
+
+ ObjCPropertyDeclInfo()
+ : DeclInfo(Info_ObjCProperty,
+ /*isRedeclaration=*/false, /*isDefinition=*/false,
+ /*isContainer=*/false) { }
+
+ static bool classof(const DeclInfo *D) {
+ return D->Kind == Info_ObjCProperty;
+ }
+ static bool classof(const ObjCPropertyDeclInfo *D) { return true; }
+};
+
struct CXXClassDeclInfo : public DeclInfo {
CXIdxCXXClassDeclInfo CXXClassInfo;
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index b028bb4602..8645b15f7b 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -158,6 +158,7 @@ clang_index_getIBOutletCollectionAttrInfo
clang_index_getObjCCategoryDeclInfo
clang_index_getObjCContainerDeclInfo
clang_index_getObjCInterfaceDeclInfo
+clang_index_getObjCPropertyDeclInfo
clang_index_getObjCProtocolRefListInfo
clang_index_isEntityObjCContainerKind
clang_index_setClientContainer