Skip to content

Commit

Permalink
[index] Set SymbolSubKind::Accessor[GS]etter on class methods
Browse files Browse the repository at this point in the history
We have the same relation between class properties and getter/setters
that we have for instance properties, so set the same symbol sub-kind.

rdar://problem/32376404

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308800 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
benlangmuir committed Jul 21, 2017
1 parent 2b20d4c commit 3094409
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
23 changes: 10 additions & 13 deletions lib/Index/IndexSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,22 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
Info.Properties |= (unsigned)SymbolProperty::UnitTest;
break;
}
case Decl::ObjCMethod:
if (cast<ObjCMethodDecl>(D)->isInstanceMethod()) {
const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(D);
Info.Kind = SymbolKind::InstanceMethod;
if (MD->isPropertyAccessor()) {
if (MD->param_size())
Info.SubKind = SymbolSubKind::AccessorSetter;
else
Info.SubKind = SymbolSubKind::AccessorGetter;
}
} else {
Info.Kind = SymbolKind::ClassMethod;
case Decl::ObjCMethod: {
const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(D);
Info.Kind = MD->isInstanceMethod() ? SymbolKind::InstanceMethod : SymbolKind::ClassMethod;
if (MD->isPropertyAccessor()) {
if (MD->param_size())
Info.SubKind = SymbolSubKind::AccessorSetter;
else
Info.SubKind = SymbolSubKind::AccessorGetter;
}
Info.Lang = SymbolLanguage::ObjC;
if (isUnitTest(cast<ObjCMethodDecl>(D)))
if (isUnitTest(MD))
Info.Properties |= (unsigned)SymbolProperty::UnitTest;
if (D->hasAttr<IBActionAttr>())
Info.Properties |= (unsigned)SymbolProperty::IBAnnotated;
break;
}
case Decl::ObjCProperty:
Info.Kind = SymbolKind::InstanceProperty;
Info.Lang = SymbolLanguage::ObjC;
Expand Down
13 changes: 11 additions & 2 deletions test/Index/Core/index-source.m
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ typedef OPAQUE(Separate) {
@interface ClassReceivers

@property(class) int p1;
// CHECK: [[@LINE-1]]:22 | class-method/acc-get/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
// CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers
// CHECK-NEXT: RelAcc | p1 | c:objc(cs)ClassReceivers(cpy)p1
// CHECK: [[@LINE-4]]:22 | class-method/acc-set/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
// CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers
// CHECK-NEXT: RelAcc | p1 | c:objc(cs)ClassReceivers(cpy)p1
// CHECK: [[@LINE-7]]:22 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Decl,RelChild | rel: 1
// CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers

+ (int)implicit;
+ (void)setImplicit:(int)x;

Expand All @@ -399,13 +408,13 @@ void classReceivers() {
// CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
// CHECK: [[@LINE-2]]:18 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Ref,Writ,RelCont | rel: 1
// CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
// CHECK: [[@LINE-4]]:18 | class-method/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Ref,Call,Impl,RelCall,RelCont | rel: 1
// CHECK: [[@LINE-4]]:18 | class-method/acc-set/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Ref,Call,Impl,RelCall,RelCont | rel: 1
// CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
(void)ClassReceivers.p1;
// CHECK: [[@LINE-1]]:9 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
// CHECK: [[@LINE-2]]:24 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Ref,RelCont | rel: 1
// CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
// CHECK: [[@LINE-4]]:24 | class-method/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Ref,Call,Impl,RelCall,RelCont | rel: 1
// CHECK: [[@LINE-4]]:24 | class-method/acc-get/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Ref,Call,Impl,RelCall,RelCont | rel: 1
// CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers

ClassReceivers.implicit = 0;
Expand Down

0 comments on commit 3094409

Please sign in to comment.