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
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index d572335..4a3e878 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1892,6 +1892,11 @@
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();
}