USRs for Objective-C methods use the USR of the @interface as their base, not the USR of the class category or extension.

llvm-svn: 124859
This commit is contained in:
Ted Kremenek 2011-02-04 07:13:40 +00:00
parent d68ec818c3
commit 05edf944c0
2 changed files with 8 additions and 20 deletions

View File

@ -119,13 +119,13 @@ int test_multi_declaration(void) {
// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@654 Extent=[57:1 - 59:5]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[58:1 - 58:14]
// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[60:1 - 62:5]
// CHECK: usrs.m c:objc(cy)CWithExt@Bar(im)meth4 Extent=[61:1 - 61:14]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth4 Extent=[61:1 - 61:14]
// CHECK: usrs.m c:objc(cs)CWithExt Extent=[63:1 - 67:2]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[64:1 - 64:27]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[65:1 - 65:27]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[66:1 - 66:27]
// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[68:1 - 70:2]
// CHECK: usrs.m c:objc(cy)CWithExt@Bar(im)meth4 Extent=[69:1 - 69:27]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth4 Extent=[69:1 - 69:27]
// CHECK: usrs.m c:@F@aux_1 Extent=[72:6 - 72:26]
// CHECK: usrs.m c:@F@test_multi_declaration Extent=[73:5 - 77:2]
// CHECK: usrs.m c:usrs.m@980@F@test_multi_declaration@foo Extent=[74:3 - 74:14]

View File

@ -283,26 +283,14 @@ void USRGenerator::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
}
void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
Decl *container = cast<Decl>(D->getDeclContext());
// The USR for a method declared in a class extension is based on
// The USR for a method declared in a class extension or category is based on
// the ObjCInterfaceDecl, not the ObjCCategoryDecl.
do {
if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(container))
if (CD->IsClassExtension()) {
// ID can be null with invalid code.
if (ObjCInterfaceDecl *ID = CD->getClassInterface()) {
Visit(ID);
break;
}
// Invalid code. Can't generate USR.
IgnoreResults = true;
return;
}
Visit(container);
ObjCInterfaceDecl *ID = D->getClassInterface();
if (!ID) {
IgnoreResults = true;
return;
}
while (false);
Visit(ID);
// Ideally we would use 'GenObjCMethod', but this is such a hot path
// for Objective-C code that we don't want to use