[llvm-branch-commits] [cfe-branch] r125039 - in /cfe/branches/Apple/sill: test/Index/usrs.m tools/libclang/CIndexUSRs.cpp
Daniel Dunbar
daniel at zuster.org
Mon Feb 7 12:00:03 PST 2011
Author: ddunbar
Date: Mon Feb 7 14:00:03 2011
New Revision: 125039
URL: http://llvm.org/viewvc/llvm-project?rev=125039&view=rev
Log:
Merge r124920:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Sat Feb 5 01:10:26 2011 +0000
Don't crash when generating USRs for ObjC methods in protocols.
Modified:
cfe/branches/Apple/sill/test/Index/usrs.m
cfe/branches/Apple/sill/tools/libclang/CIndexUSRs.cpp
Modified: cfe/branches/Apple/sill/test/Index/usrs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/sill/test/Index/usrs.m?rev=125039&r1=125038&r2=125039&view=diff
==============================================================================
--- cfe/branches/Apple/sill/test/Index/usrs.m (original)
+++ cfe/branches/Apple/sill/test/Index/usrs.m Mon Feb 7 14:00:03 2011
@@ -76,6 +76,10 @@
return 0;
}
+ at protocol P1
+- (void)method;
+ at end
+
// CHECK: usrs.m c:usrs.m at 85@F at my_helper Extent=[3:19 - 3:60]
// CHECK: usrs.m c:usrs.m at 95@F at my_helper@x Extent=[3:29 - 3:34]
// CHECK: usrs.m c:usrs.m at 102@F at my_helper@y Extent=[3:36 - 3:41]
@@ -131,6 +135,8 @@
// CHECK: usrs.m c:usrs.m at 980@F at test_multi_declaration@foo Extent=[74:3 - 74:14]
// CHECK: usrs.m c:usrs.m at 980@F at test_multi_declaration@bar Extent=[74:16 - 74:23]
// CHECK: usrs.m c:usrs.m at 980@F at test_multi_declaration@baz Extent=[74:25 - 74:32]
+// CHECK: usrs.m c:objc(pl)P1 Extent=[79:1 - 81:5]
+// CHECK: usrs.m c:objc(pl)P1(im)method Extent=[80:1 - 80:16]
// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix=CHECK-source %s
// CHECK-source: usrs.m:3:19: FunctionDecl=my_helper:3:19 (Definition) Extent=[3:19 - 3:60]
@@ -259,6 +265,6 @@
// CHECK-source: usrs.m:75:19: DeclRefExpr=baz:74:25 Extent=[75:19 - 75:22]
// CHECK-source: usrs.m:76:3: UnexposedStmt= Extent=[76:3 - 76:11]
// CHECK-source: usrs.m:76:10: UnexposedExpr= Extent=[76:10 - 76:11]
-
-
+// CHECK-source: usrs.m:79:1: ObjCProtocolDecl=P1:79:1 (Definition) Extent=[79:1 - 81:5]
+// CHECK-source: usrs.m:80:1: ObjCInstanceMethodDecl=method:80:1 Extent=[80:1 - 80:16]
Modified: cfe/branches/Apple/sill/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/sill/tools/libclang/CIndexUSRs.cpp?rev=125039&r1=125038&r2=125039&view=diff
==============================================================================
--- cfe/branches/Apple/sill/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/branches/Apple/sill/tools/libclang/CIndexUSRs.cpp Mon Feb 7 14:00:03 2011
@@ -283,15 +283,20 @@
}
void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
- // The USR for a method declared in a class extension or category is based on
- // the ObjCInterfaceDecl, not the ObjCCategoryDecl.
- ObjCInterfaceDecl *ID = D->getClassInterface();
- if (!ID) {
- IgnoreResults = true;
- return;
+ DeclContext *container = D->getDeclContext();
+ if (ObjCProtocolDecl *pd = dyn_cast<ObjCProtocolDecl>(container)) {
+ Visit(pd);
+ }
+ else {
+ // The USR for a method declared in a class extension or category is based on
+ // the ObjCInterfaceDecl, not the ObjCCategoryDecl.
+ ObjCInterfaceDecl *ID = D->getClassInterface();
+ if (!ID) {
+ IgnoreResults = true;
+ return;
+ }
+ Visit(ID);
}
- 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
// DeclarationName::getAsString().
More information about the llvm-branch-commits
mailing list