aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-17 01:56:48 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-17 01:56:48 +0000
commit673c5d5e22b0af17bb9e903862f39e8a23d9e47f (patch)
tree2292d57adeab1f8dac0c99a55b5e03a6a5f26686 /lib/AST/Decl.cpp
parentf2fee9aa3c2a69465e5ad20d3d0c368eb430562c (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index d572335fb3..4a3e8781de 100644
--- a/lib/AST/Decl.cpp
+++ b/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();
}