mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 05:16:06 +00:00
[index] When indexing an ObjC method declaration use its base name for the location.
Instead of using the location of the beginning '-'/'+'. This is consistent with location used for function decls and ObjC method calls where we use the base name as the location as well. llvm-svn: 293134
This commit is contained in:
parent
647d34fe61
commit
aee15fb204
@ -92,7 +92,13 @@ public:
|
|||||||
Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
|
Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
|
||||||
AssociatedProp);
|
AssociatedProp);
|
||||||
|
|
||||||
if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
|
// getLocation() returns beginning token of a method declaration, but for
|
||||||
|
// indexing purposes we want to point to the base name.
|
||||||
|
SourceLocation MethodLoc = D->getSelectorStartLoc();
|
||||||
|
if (MethodLoc.isInvalid())
|
||||||
|
MethodLoc = D->getLocation();
|
||||||
|
|
||||||
|
if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, Relations))
|
||||||
return false;
|
return false;
|
||||||
IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
|
IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
|
||||||
bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>();
|
bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>();
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
@interface Base
|
@interface Base
|
||||||
// CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Decl | rel: 0
|
// CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Decl | rel: 0
|
||||||
-(void)meth;
|
-(void)meth;
|
||||||
// CHECK: [[@LINE-1]]:1 | instance-method/ObjC | meth | c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
|
||||||
// CHECK-NEXT: RelChild | Base | c:objc(cs)Base
|
// CHECK-NEXT: RelChild | Base | c:objc(cs)Base
|
||||||
+(Base*)class_meth;
|
+(Base*)class_meth;
|
||||||
// CHECK: [[@LINE-1]]:1 | class-method/ObjC | class_meth | c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1
|
||||||
// CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
|
// CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
|
||||||
// CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth
|
// CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ extern int setjmp(jmp_buf);
|
|||||||
|
|
||||||
@class I1;
|
@class I1;
|
||||||
@interface I1
|
@interface I1
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
|
||||||
-(void)meth;
|
-(void)meth;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ extern int setjmp(jmp_buf);
|
|||||||
// CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
|
// CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
|
||||||
@synthesize prop = _prop;
|
@synthesize prop = _prop;
|
||||||
|
|
||||||
// CHECK: [[@LINE+5]]:1 | instance-method(IB)/ObjC | doAction:foo: | c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+5]]:12 | instance-method(IB)/ObjC | doAction:foo: | c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: 1
|
||||||
// CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
|
// CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
|
||||||
// CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1
|
// CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1
|
||||||
// CHECK-NEXT: RelCont,RelIBType | doAction:foo: | c:objc(cs)I2(im)doAction:foo:
|
// CHECK-NEXT: RelCont,RelIBType | doAction:foo: | c:objc(cs)I2(im)doAction:foo:
|
||||||
@ -127,11 +127,11 @@ extern int setjmp(jmp_buf);
|
|||||||
|
|
||||||
@interface I3
|
@interface I3
|
||||||
@property (readwrite) id prop;
|
@property (readwrite) id prop;
|
||||||
// CHECK: [[@LINE+3]]:1 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2
|
// CHECK: [[@LINE+3]]:6 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2
|
||||||
// CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
|
// CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
|
||||||
// CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop
|
// CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop
|
||||||
-(id)prop;
|
-(id)prop;
|
||||||
// CHECK: [[@LINE+3]]:1 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Decl,Dyn,RelChild,RelAcc | rel: 2
|
// CHECK: [[@LINE+3]]:8 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Decl,Dyn,RelChild,RelAcc | rel: 2
|
||||||
// CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
|
// CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
|
||||||
// CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop
|
// CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop
|
||||||
-(void)setProp:(id)p;
|
-(void)setProp:(id)p;
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
@end
|
@end
|
||||||
// CHECK: [[@LINE+1]]:17 | class(test)/ObjC | MyTestCase | c:objc(cs)MyTestCase | <no-cgname> | Def | rel: 0
|
// CHECK: [[@LINE+1]]:17 | class(test)/ObjC | MyTestCase | c:objc(cs)MyTestCase | <no-cgname> | Def | rel: 0
|
||||||
@implementation MyTestCase
|
@implementation MyTestCase
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method(test)/ObjC | testMe | c:objc(cs)MyTestCase(im)testMe | -[MyTestCase testMe] | Def,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:8 | instance-method(test)/ObjC | testMe | c:objc(cs)MyTestCase(im)testMe | -[MyTestCase testMe] | Def,Dyn,RelChild | rel: 1
|
||||||
-(void)testMe {}
|
-(void)testMe {}
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | testResult | c:objc(cs)MyTestCase(im)testResult | -[MyTestCase testResult] | Def,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:6 | instance-method/ObjC | testResult | c:objc(cs)MyTestCase(im)testResult | -[MyTestCase testResult] | Def,Dyn,RelChild | rel: 1
|
||||||
-(id)testResult { return 0; }
|
-(id)testResult { return 0; }
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | testWithInt: | c:objc(cs)MyTestCase(im)testWithInt: | -[MyTestCase testWithInt:] | Def,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | testWithInt: | c:objc(cs)MyTestCase(im)testWithInt: | -[MyTestCase testWithInt:] | Def,Dyn,RelChild | rel: 1
|
||||||
-(void)testWithInt:(int)i {}
|
-(void)testWithInt:(int)i {}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
@end
|
@end
|
||||||
// CHECK: [[@LINE+1]]:17 | class(test)/ObjC | SubTestCase | c:objc(cs)SubTestCase | <no-cgname> | Def | rel: 0
|
// CHECK: [[@LINE+1]]:17 | class(test)/ObjC | SubTestCase | c:objc(cs)SubTestCase | <no-cgname> | Def | rel: 0
|
||||||
@implementation SubTestCase
|
@implementation SubTestCase
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method(test)/ObjC | testIt2 | c:objc(cs)SubTestCase(im)testIt2 | -[SubTestCase testIt2] | Def,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:8 | instance-method(test)/ObjC | testIt2 | c:objc(cs)SubTestCase(im)testIt2 | -[SubTestCase testIt2] | Def,Dyn,RelChild | rel: 1
|
||||||
-(void)testIt2 {}
|
-(void)testIt2 {}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -34,7 +34,7 @@
|
|||||||
// CHECK: [[@LINE+2]]:17 | class(test)/ObjC | MyTestCase | c:objc(cs)MyTestCase | _OBJC_CLASS_$_MyTestCase | Ref,RelCont | rel: 1
|
// CHECK: [[@LINE+2]]:17 | class(test)/ObjC | MyTestCase | c:objc(cs)MyTestCase | _OBJC_CLASS_$_MyTestCase | Ref,RelCont | rel: 1
|
||||||
// CHECK: [[@LINE+1]]:28 | extension/ObjC | MyTestCase | c:objc(cy)MyTestCase@cat | <no-cgname> | Def | rel: 0
|
// CHECK: [[@LINE+1]]:28 | extension/ObjC | MyTestCase | c:objc(cy)MyTestCase@cat | <no-cgname> | Def | rel: 0
|
||||||
@implementation MyTestCase(cat)
|
@implementation MyTestCase(cat)
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method(test)/ObjC | testInCat | c:objc(cs)MyTestCase(im)testInCat | -[MyTestCase(cat) testInCat] | Def,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:9 | instance-method(test)/ObjC | testInCat | c:objc(cs)MyTestCase(im)testInCat | -[MyTestCase(cat) testInCat] | Def,Dyn,RelChild | rel: 1
|
||||||
- (void)testInCat {}
|
- (void)testInCat {}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -47,7 +47,7 @@
|
|||||||
@property (readonly) IBOutlet id prop;
|
@property (readonly) IBOutlet id prop;
|
||||||
// CHECK: [[@LINE+1]]:54 | instance-property(IB,IBColl)/ObjC | propColl | c:objc(cs)IBCls(py)propColl | <no-cgname> | Decl,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:54 | instance-property(IB,IBColl)/ObjC | propColl | c:objc(cs)IBCls(py)propColl | <no-cgname> | Decl,RelChild | rel: 1
|
||||||
@property (readonly) IBOutletCollection(NSButton) id propColl;
|
@property (readonly) IBOutletCollection(NSButton) id propColl;
|
||||||
// CHECK: [[@LINE+1]]:1 | instance-method(IB)/ObjC | doIt | c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1
|
// CHECK: [[@LINE+1]]:12 | instance-method(IB)/ObjC | doIt | c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1
|
||||||
-(IBAction)doIt;
|
-(IBAction)doIt;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ int test1() {
|
|||||||
// RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t
|
// RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t
|
||||||
// RUN: FileCheck %s -input-file=%t
|
// RUN: FileCheck %s -input-file=%t
|
||||||
// CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12
|
// CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12
|
||||||
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2
|
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:7
|
||||||
// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25
|
// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25
|
||||||
// CHECK: [indexDeclaration]: kind: objc-category | name: | {{.*}} | loc: 6:12
|
// CHECK: [indexDeclaration]: kind: objc-category | name: | {{.*}} | loc: 6:12
|
||||||
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 7:33
|
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 7:33
|
||||||
@ -82,5 +82,5 @@ int test1() {
|
|||||||
// CHECK-NOT: [indexDeclaration]: kind: objc-instance-method {{.*}} loc: 37:
|
// CHECK-NOT: [indexDeclaration]: kind: objc-instance-method {{.*}} loc: 37:
|
||||||
// CHECK-NOT: [indexDeclaration]: kind: objc-instance-method {{.*}} loc: 43:
|
// CHECK-NOT: [indexDeclaration]: kind: objc-instance-method {{.*}} loc: 43:
|
||||||
|
|
||||||
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: meth | {{.*}} loc: 54:1 | {{.*}} | isRedecl: 0 | isDef: 0 |
|
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: meth | {{.*}} loc: 54:8 | {{.*}} | isRedecl: 0 | isDef: 0 |
|
||||||
// CHECK: [indexDeclaration]: kind: objc-property | name: c | USR: c:objc(cs)I5(cpy)c | lang: ObjC | cursor: ObjCPropertyDecl=c:55:23 [class,] | loc: 55:23
|
// CHECK: [indexDeclaration]: kind: objc-property | name: c | USR: c:objc(cs)I5(cpy)c | lang: ObjC | cursor: ObjCPropertyDecl=c:55:23 [class,] | loc: 55:23
|
||||||
|
@ -52,7 +52,7 @@ int glob;
|
|||||||
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class | name: Module | {{.*}} | loc: [[TMOD_MODULE_H]]:15:12
|
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class | name: Module | {{.*}} | loc: [[TMOD_MODULE_H]]:15:12
|
||||||
// CHECK-TMOD-NEXT: <ObjCContainerInfo>: kind: interface
|
// CHECK-TMOD-NEXT: <ObjCContainerInfo>: kind: interface
|
||||||
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class-method | name: version | {{.*}} | loc: [[TMOD_MODULE_H]]:16:1
|
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class-method | name: version | {{.*}} | loc: [[TMOD_MODULE_H]]:16:1
|
||||||
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class-method | name: alloc | {{.*}} | loc: [[TMOD_MODULE_H]]:17:1
|
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class-method | name: alloc | {{.*}} | loc: [[TMOD_MODULE_H]]:17:2
|
||||||
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: typedef | name: FILE | {{.*}} | loc: [[TMOD_MODULE_H]]:30:3
|
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: typedef | name: FILE | {{.*}} | loc: [[TMOD_MODULE_H]]:30:3
|
||||||
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: struct | name: __sFILE | {{.*}} | loc: [[TMOD_MODULE_H]]:28:16
|
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: struct | name: __sFILE | {{.*}} | loc: [[TMOD_MODULE_H]]:28:16
|
||||||
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: field | name: _offset | {{.*}} | loc: [[TMOD_MODULE_H]]:29:7
|
// CHECK-TMOD-NEXT: [indexDeclaration]: kind: field | name: _offset | {{.*}} | loc: [[TMOD_MODULE_H]]:29:7
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
if (isa<ObjCImplDecl>(LexicalDC) && !D->isThisDeclarationADefinition())
|
if (isa<ObjCImplDecl>(LexicalDC) && !D->isThisDeclarationADefinition())
|
||||||
DataConsumer.handleSynthesizedObjCMethod(D, DeclLoc, LexicalDC);
|
DataConsumer.handleSynthesizedObjCMethod(D, DeclLoc, LexicalDC);
|
||||||
else
|
else
|
||||||
DataConsumer.handleObjCMethod(D);
|
DataConsumer.handleObjCMethod(D, DeclLoc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,7 +801,8 @@ bool CXIndexDataConsumer::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D)
|
|||||||
return handleObjCContainer(D, CategoryLoc, getCursor(D), CatDInfo);
|
return handleObjCContainer(D, CategoryLoc, getCursor(D), CatDInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CXIndexDataConsumer::handleObjCMethod(const ObjCMethodDecl *D) {
|
bool CXIndexDataConsumer::handleObjCMethod(const ObjCMethodDecl *D,
|
||||||
|
SourceLocation Loc) {
|
||||||
bool isDef = D->isThisDeclarationADefinition();
|
bool isDef = D->isThisDeclarationADefinition();
|
||||||
bool isContainer = isDef;
|
bool isContainer = isDef;
|
||||||
bool isSkipped = false;
|
bool isSkipped = false;
|
||||||
@ -814,7 +815,7 @@ bool CXIndexDataConsumer::handleObjCMethod(const ObjCMethodDecl *D) {
|
|||||||
DeclInfo DInfo(!D->isCanonicalDecl(), isDef, isContainer);
|
DeclInfo DInfo(!D->isCanonicalDecl(), isDef, isContainer);
|
||||||
if (isSkipped)
|
if (isSkipped)
|
||||||
DInfo.flags |= CXIdxDeclFlag_Skipped;
|
DInfo.flags |= CXIdxDeclFlag_Skipped;
|
||||||
return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
|
return handleDecl(D, Loc, getCursor(D), DInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CXIndexDataConsumer::handleSynthesizedObjCProperty(
|
bool CXIndexDataConsumer::handleSynthesizedObjCProperty(
|
||||||
|
@ -418,7 +418,7 @@ public:
|
|||||||
bool handleObjCCategory(const ObjCCategoryDecl *D);
|
bool handleObjCCategory(const ObjCCategoryDecl *D);
|
||||||
bool handleObjCCategoryImpl(const ObjCCategoryImplDecl *D);
|
bool handleObjCCategoryImpl(const ObjCCategoryImplDecl *D);
|
||||||
|
|
||||||
bool handleObjCMethod(const ObjCMethodDecl *D);
|
bool handleObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc);
|
||||||
|
|
||||||
bool handleSynthesizedObjCProperty(const ObjCPropertyImplDecl *D);
|
bool handleSynthesizedObjCProperty(const ObjCPropertyImplDecl *D);
|
||||||
bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc,
|
bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user