USRs for class extensions should "mangle" in the location of the extension. (<rdar://problem/8350262>)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111991 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2010-08-24 23:13:41 +00:00
Родитель 957355ebf6
Коммит 28a7f258ae
2 изменённых файлов: 49 добавлений и 8 удалений

Просмотреть файл

@ -49,12 +49,24 @@ int z;
static int local_func(int x) { return x; }
@interface CWithExt
- (id) meth1;
@end
@interface CWithExt ()
- (id) meth2;
@end
@interface CWithExt ()
- (id) meth3;
@end
@interface CWithExt (Bar)
- (id) meth4;
@end
@implementation CWithExt
- (id) meth1 { return 0; }
- (id) meth2 { return 0; }
- (id) meth3 { return 0; }
@end
@implementation CWithExt (Bar)
- (id) meth4 { return 0; }
@end
// CHECK: usrs.m c:usrs.m@85@F@my_helper Extent=[3:19 - 3:60]
@ -93,10 +105,18 @@ static int local_func(int x) { return x; }
// CHECK: usrs.m c:@z Extent=[47:1 - 47:6]
// CHECK: usrs.m c:usrs.m@540@F@local_func Extent=[49:12 - 49:43]
// CHECK: usrs.m c:usrs.m@551@F@local_func@x Extent=[49:23 - 49:28]
// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 52:5]
// CHECK: usrs.m c:objc(cy)CWithExt@ Extent=[53:1 - 54:5]
// CHECK: usrs.m c:objc(cy)CWithExt@ Extent=[55:1 - 56:5]
// CHECK: usrs.m c:objc(cs)CWithExt Extent=[57:1 - 58:2]
// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 53:5]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[52:1 - 52:14]
// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@612 Extent=[54:1 - 56:5]
// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[55:1 - 55:14]
// 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 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]

Просмотреть файл

@ -227,7 +227,20 @@ void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) {
}
void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
Visit(cast<Decl>(D->getDeclContext()));
Decl *container = cast<Decl>(D->getDeclContext());
// The USR for a method declared in a class extension is based on
// the ObjCInterfaceDecl, not the ObjCCategoryDecl.
do {
if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(container))
if (CD->IsClassExtension()) {
Visit(CD->getClassInterface());
break;
}
Visit(cast<Decl>(D->getDeclContext()));
}
while (false);
// Ideally we would use 'GenObjCMethod', but this is such a hot path
// for Objective-C code that we don't want to use
// DeclarationName::getAsString().
@ -267,7 +280,15 @@ void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) {
IgnoreResults = true;
return;
}
GenObjCCategory(ID->getName(), CD->getName());
// Specially handle class extensions, which are anonymous categories.
// We want to mangle in the location to uniquely distinguish them.
if (CD->IsClassExtension()) {
Out << "objc(ext)" << ID->getName() << '@';
GenLoc(CD);
}
else
GenObjCCategory(ID->getName(), CD->getName());
break;
}
case Decl::ObjCCategoryImpl: {