diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-17 01:56:48 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-17 01:56:48 +0000 |
commit | a077279184e39f7ec25e1a491e47bf51c25355d5 (patch) | |
tree | ef88c0a0ac9c30c3d8693763daee5de2e90afb81 /clang | |
parent | 406503a0f908196e67322500502ccc13c928c2f4 (diff) | |
download | bcm5719-llvm-a077279184e39f7ec25e1a491e47bf51c25355d5.tar.gz bcm5719-llvm-a077279184e39f7ec25e1a491e47bf51c25355d5.zip |
Correct the range returned by ParmVarDecl::getSourceRange(), for parameters in ObjC methods with postfix types.
For a parameter in a method like this:
-(int)methodWithFn:(void (*)(int *p))fn;
we would return the source range of the type and not include the parameter name.
Fixes rdar://13668626.
llvm-svn: 179660
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 5 | ||||
-rw-r--r-- | clang/test/Index/usrs.m | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index d572335fb3d..4a3e8781dee 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1892,6 +1892,11 @@ SourceRange ParmVarDecl::getSourceRange() const { return SourceRange(getOuterLocStart(), ArgRange.getEnd()); } + // DeclaratorDecl considers the range of postfix types as overlapping with the + // declaration name, but this is not the case with parameters in ObjC methods. + if (isa<ObjCMethodDecl>(getDeclContext())) + return SourceRange(DeclaratorDecl::getLocStart(), getLocation()); + return DeclaratorDecl::getSourceRange(); } diff --git a/clang/test/Index/usrs.m b/clang/test/Index/usrs.m index be0e323c936..dccfb758727 100644 --- a/clang/test/Index/usrs.m +++ b/clang/test/Index/usrs.m @@ -86,6 +86,7 @@ int test_multi_declaration(void) { id var_ext; } @property (assign) id pro_ext; +-(int)methodWithFn:(void (*)(int *p))fn; @end // RUN: c-index-test -test-load-source-usrs all -target x86_64-apple-macosx10.7 %s | FileCheck %s @@ -146,7 +147,7 @@ int test_multi_declaration(void) { // 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] // CHECK: usrs.m c:objc(cs)CWithExt2 Extent=[83:1 - 84:5] -// CHECK: usrs.m c:objc(ext)CWithExt2@usrs.m@1111 Extent=[85:1 - 89:5] +// CHECK: usrs.m c:objc(ext)CWithExt2@usrs.m@1111 Extent=[85:1 - 90:5] // CHECK: usrs.m c:objc(cs)CWithExt2@var_ext Extent=[86:3 - 86:13] // CHECK: usrs.m c:objc(cs)CWithExt2(py)pro_ext Extent=[88:1 - 88:30] // CHECK: usrs.m c:objc(cs)CWithExt2(im)pro_ext Extent=[88:23 - 88:30] @@ -279,4 +280,6 @@ int test_multi_declaration(void) { // CHECK-source: usrs.m:76:10: IntegerLiteral= Extent=[76:10 - 76:11] // CHECK-source: usrs.m:79:11: ObjCProtocolDecl=P1:79:11 (Definition) Extent=[79:1 - 81:5] // CHECK-source: usrs.m:80:9: ObjCInstanceMethodDecl=method:80:9 Extent=[80:1 - 80:16] - +// CHECK-source: usrs.m:89:7: ObjCInstanceMethodDecl=methodWithFn::89:7 Extent=[89:1 - 89:41] +// CHECK-source: usrs.m:89:38: ParmDecl=fn:89:38 (Definition) Extent=[89:21 - 89:40] +// CHECK-source: usrs.m:89:35: ParmDecl=p:89:35 (Definition) Extent=[89:30 - 89:36] |