From: Argyrios Kyrtzidis Date: Mon, 6 May 2013 19:08:57 +0000 (+0000) Subject: Have the RecursiveASTVisitor traverse the type source info of an objc class message. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1270673bf5208a140b397419c8c34e7bdcce2339;p=clang Have the RecursiveASTVisitor traverse the type source info of an objc class message. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181237 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index eb5a8123c2..b5a4b5e36d 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -2195,7 +2195,10 @@ DEF_TRAVERSE_STMT(ObjCEncodeExpr, { }) DEF_TRAVERSE_STMT(ObjCIsaExpr, { }) DEF_TRAVERSE_STMT(ObjCIvarRefExpr, { }) -DEF_TRAVERSE_STMT(ObjCMessageExpr, { }) +DEF_TRAVERSE_STMT(ObjCMessageExpr, { + if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo()) + TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); +}) DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, { }) DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, { }) DEF_TRAVERSE_STMT(ObjCProtocolExpr, { }) diff --git a/test/Index/index-refs.m b/test/Index/index-refs.m index b82345f9c6..f25013b882 100644 --- a/test/Index/index-refs.m +++ b/test/Index/index-refs.m @@ -13,6 +13,15 @@ void foo() { @encode(struct FooS); } +@interface I ++(void)clsMeth; +@end + +void foo2() { + [I clsMeth]; +} + // RUN: c-index-test -index-file %s | FileCheck %s // CHECK: [indexEntityReference]: kind: objc-protocol | name: Prot | {{.*}} | loc: 12:27 // CHECK: [indexEntityReference]: kind: struct | name: FooS | {{.*}} | loc: 13:18 +// CHECK: [indexEntityReference]: kind: objc-class | name: I | {{.*}} | loc: 21:4 diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp index 54711e6332..02ab885e62 100644 --- a/tools/libclang/IndexBody.cpp +++ b/tools/libclang/IndexBody.cpp @@ -68,9 +68,6 @@ public: } bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - if (TypeSourceInfo *Cls = E->getClassReceiverTypeInfo()) - IndexCtx.indexTypeSourceInfo(Cls, Parent, ParentDC); - if (ObjCMethodDecl *MD = E->getMethodDecl()) IndexCtx.handleReference(MD, E->getSelectorStartLoc(), Parent, ParentDC, E, diff --git a/tools/libclang/RecursiveASTVisitor.h b/tools/libclang/RecursiveASTVisitor.h index dd2c836d9c..e45545ed1a 100644 --- a/tools/libclang/RecursiveASTVisitor.h +++ b/tools/libclang/RecursiveASTVisitor.h @@ -2116,7 +2116,10 @@ DEF_TRAVERSE_STMT(ObjCEncodeExpr, { }) DEF_TRAVERSE_STMT(ObjCIsaExpr, { }) DEF_TRAVERSE_STMT(ObjCIvarRefExpr, { }) -DEF_TRAVERSE_STMT(ObjCMessageExpr, { }) +DEF_TRAVERSE_STMT(ObjCMessageExpr, { + if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo()) + TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); +}) DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, { }) DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, { }) DEF_TRAVERSE_STMT(ObjCProtocolExpr, { })