[cfe-commits] r142355 - in /cfe/trunk: include/clang-c/Index.h tools/c-index-test/c-index-test.c tools/libclang/IndexBody.cpp tools/libclang/IndexingContext.cpp tools/libclang/IndexingContext.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Oct 18 08:50:50 PDT 2011
Author: akirtzidis
Date: Tue Oct 18 10:50:50 2011
New Revision: 142355
URL: http://llvm.org/viewvc/llvm-project?rev=142355&view=rev
Log:
[libclang] Index implicit property references.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/IndexBody.cpp
cfe/trunk/tools/libclang/IndexingContext.cpp
cfe/trunk/tools/libclang/IndexingContext.h
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=142355&r1=142354&r2=142355&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Oct 18 10:50:50 2011
@@ -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 {
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=142355&r1=142354&r2=142355&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Oct 18 10:50:50 2011
@@ -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");
}
Modified: cfe/trunk/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexBody.cpp?rev=142355&r1=142354&r2=142355&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexBody.cpp (original)
+++ cfe/trunk/tools/libclang/IndexBody.cpp Tue Oct 18 10:50:50 2011
@@ -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
Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=142355&r1=142354&r2=142355&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Tue Oct 18 10:50:50 2011
@@ -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);
}
Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=142355&r1=142354&r2=142355&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Tue Oct 18 10:50:50 2011
@@ -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);
More information about the cfe-commits
mailing list