summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-04-16 20:01:28 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-04-16 20:01:28 +0000
commit9482a185d34d8b0f6d788c44e2c128991622c0ad (patch)
tree40183da11c9b17d678a310caa0f0be6e9fb834ba
parent3c6ed1b5c50de8ab9375e59fd68ea2a9e5ae8c30 (diff)
[libclang] Spelling range for a objc category should the category name range, not the class one.
rdar://11249386 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154853 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Index/get-cursor.m10
-rw-r--r--tools/libclang/CIndex.cpp12
2 files changed, 22 insertions, 0 deletions
diff --git a/test/Index/get-cursor.m b/test/Index/get-cursor.m
index 60e35eedd4..b8d82ac70b 100644
--- a/test/Index/get-cursor.m
+++ b/test/Index/get-cursor.m
@@ -60,6 +60,13 @@ void foo3(Test3 *test3) {
[test3 setFoo:2 withBar:4];
}
+@interface Test4
+@end
+@interface Test4(Dido)
+@end
+@implementation Test4(Dido)
+@end
+
// RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
// CHECK-PROP: ObjCPropertyDecl=foo1:4:26
// CHECK-PROP: ObjCPropertyDecl=foo2:5:27
@@ -82,6 +89,9 @@ void foo3(Test3 *test3) {
// CHECK-MEMBERREF: 52:11 MemberRefExpr=setImplicitProp::46:8 Extent=[52:5 - 52:23] Spelling=setImplicitProp: ([52:11 - 52:23])
// RUN: c-index-test -cursor-at=%s:56:24 -cursor-at=%s:60:14 \
+// RUN: -cursor-at=%s:65:20 -cursor-at=%s:67:25 \
// RUN: %s | FileCheck -check-prefix=CHECK-SPELLRANGE %s
// CHECK-SPELLRANGE: 56:8 ObjCInstanceMethodDecl=setFoo:withBar::56:8 Extent=[56:1 - 56:37] Spelling=setFoo:withBar: ([56:8 - 56:14][56:22 - 56:29]) Selector index=1
// CHECK-SPELLRANGE: 60:3 ObjCMessageExpr=setFoo:withBar::56:8 Extent=[60:3 - 60:29] Spelling=setFoo:withBar: ([60:10 - 60:16][60:19 - 60:26]) Selector index=0
+// CHECK-SPELLRANGE: 65:12 ObjCCategoryDecl=Dido:65:12 Extent=[65:1 - 66:5] Spelling=Dido ([65:18 - 65:22])
+// CHECK-SPELLRANGE: 67:17 ObjCCategoryImplDecl=Dido:67:17 (Definition) Extent=[67:1 - 68:2] Spelling=Dido ([67:23 - 67:27])
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index ece91ce20e..ec8fc01dd2 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -3196,6 +3196,18 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
}
}
+ if (C.kind == CXCursor_ObjCCategoryDecl ||
+ C.kind == CXCursor_ObjCCategoryImplDecl) {
+ if (pieceIndex > 0)
+ return clang_getNullRange();
+ if (ObjCCategoryDecl *
+ CD = dyn_cast_or_null<ObjCCategoryDecl>(getCursorDecl(C)))
+ return cxloc::translateSourceRange(Ctx, CD->getCategoryNameLoc());
+ if (ObjCCategoryImplDecl *
+ CID = dyn_cast_or_null<ObjCCategoryImplDecl>(getCursorDecl(C)))
+ return cxloc::translateSourceRange(Ctx, CID->getCategoryNameLoc());
+ }
+
// FIXME: A CXCursor_InclusionDirective should give the location of the
// filename, but we don't keep track of this.