From: Manman Ren Date: Tue, 31 May 2016 23:22:04 +0000 (+0000) Subject: Indexer: add CXObjCPropertyAttr_class for class properties. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4b3e8287556482c56c6414ba755f8ee1834ae13;p=clang Indexer: add CXObjCPropertyAttr_class for class properties. rdar://25963227 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271351 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index dbcd0c8840..896d317732 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -3911,7 +3911,8 @@ typedef enum { CXObjCPropertyAttr_atomic = 0x100, CXObjCPropertyAttr_weak = 0x200, CXObjCPropertyAttr_strong = 0x400, - CXObjCPropertyAttr_unsafe_unretained = 0x800 + CXObjCPropertyAttr_unsafe_unretained = 0x800, + CXObjCPropertyAttr_class = 0x4000 } CXObjCPropertyAttrKind; /** diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 29c3739767..52f3a56d98 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -73,6 +73,7 @@ struct X0 {}; @interface TestAttributes() // @property (retain) IBOutlet id anotherOutlet; +@property (class) int cProp; @end // CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 12:5] @@ -167,7 +168,7 @@ struct X0 {}; // CHECK: c-index-api-loadTU-test.m:69:16: TypeRef=struct X0:71:8 Extent=[69:16 - 69:18] // CHECK: c-index-api-loadTU-test.m:70:8: StructDecl=X0:70:8 Extent=[70:1 - 70:10] // CHECK: c-index-api-loadTU-test.m:71:8: StructDecl=X0:71:8 (Definition) Extent=[71:1 - 71:14] -// CHECK: c-index-api-loadTU-test.m:73:12: ObjCCategoryDecl=:73:12 Extent=[73:1 - 76:5] +// CHECK: c-index-api-loadTU-test.m:73:12: ObjCCategoryDecl=:73:12 Extent=[73:1 - 77:5] // CHECK: c-index-api-loadTU-test.m:73:12: ObjCClassRef=TestAttributes:62:12 Extent=[73:12 - 73:26] // CHECK: c-index-api-loadTU-test.m:75:32: ObjCPropertyDecl=anotherOutlet:75:32 [retain,] Extent=[75:1 - 75:45] // CHECK: c-index-api-loadTU-test.m:75:20: attribute(iboutlet)= Extent=[75:20 - 75:28] @@ -175,3 +176,7 @@ struct X0 {}; // CHECK: c-index-api-loadTU-test.m:75:32: ObjCInstanceMethodDecl=anotherOutlet:75:32 Extent=[75:32 - 75:45] // CHECK: c-index-api-loadTU-test.m:75:32: ObjCInstanceMethodDecl=setAnotherOutlet::75:32 Extent=[75:32 - 75:45] // CHECK: c-index-api-loadTU-test.m:75:32: ParmDecl=anotherOutlet:75:32 (Definition) Extent=[75:32 - 75:45] +// CHECK: c-index-api-loadTU-test.m:76:23: ObjCPropertyDecl=cProp:76:23 [class,] Extent=[76:1 - 76:28] +// CHECK: c-index-api-loadTU-test.m:76:23: ObjCClassMethodDecl=cProp:76:23 Extent=[76:23 - 76:28] +// CHECK: c-index-api-loadTU-test.m:76:23: ObjCClassMethodDecl=setCProp::76:23 Extent=[76:23 - 76:28] +// CHECK: c-index-api-loadTU-test.m:76:23: ParmDecl=cProp:76:23 (Definition) Extent=[76:23 - 76:28] diff --git a/test/Index/print-type.m b/test/Index/print-type.m index 777069b3a5..392399a573 100644 --- a/test/Index/print-type.m +++ b/test/Index/print-type.m @@ -4,6 +4,7 @@ -(const id) mymethod2:(id)x blah:(Class)y boo:(SEL)z; -(bycopy)methodIn:(in int)i andOut:(out short *)j , ...; -(void)kindof_meth:(__kindof Foo *)p; +@property (class) int classProp; @end // RUN: c-index-test -test-print-type %s | FileCheck %s @@ -15,3 +16,4 @@ // CHECK: ParmDecl=i:5:27 (Definition) [In,] [type=int] [typekind=Int] [isPOD=1] // CHECK: ParmDecl=j:5:49 (Definition) [Out,] [type=short *] [typekind=Pointer] [isPOD=1] [pointeetype=short] [pointeekind=Short] // CHECK: ParmDecl=p:6:36 (Definition) [type=__kindof Foo *] [typekind=ObjCObjectPointer] [canonicaltype=__kindof Foo *] [canonicaltypekind=ObjCObjectPointer] [isPOD=1] [pointeetype=Foo] [pointeekind=ObjCInterface] +// CHECK: ObjCPropertyDecl=classProp:7:23 [class,] [type=int] [typekind=Int] [isPOD=1] diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 802140a350..5bf5f3d019 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -937,6 +937,7 @@ static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) { PRINT_PROP_ATTR(weak); PRINT_PROP_ATTR(strong); PRINT_PROP_ATTR(unsafe_unretained); + PRINT_PROP_ATTR(class); printf("]"); } } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 78df3ce264..20ca641968 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -6720,6 +6720,7 @@ static void clang_annotateTokensImpl(CXTranslationUnit TU, ASTUnit *CXXUnit, .Case("setter", true) .Case("strong", true) .Case("weak", true) + .Case("class", true) .Default(false)) Tokens[I].int_data[0] = CXToken_Keyword; } @@ -7166,6 +7167,7 @@ unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved) { SET_CXOBJCPROP_ATTR(weak); SET_CXOBJCPROP_ATTR(strong); SET_CXOBJCPROP_ATTR(unsafe_unretained); + SET_CXOBJCPROP_ATTR(class); #undef SET_CXOBJCPROP_ATTR return Result;