Fix crash when using archaic protocol, rdar://10238337
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141215 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/SelectorLocationsKind.cpp b/lib/AST/SelectorLocationsKind.cpp
index 9a44b38..671207a 100644
--- a/lib/AST/SelectorLocationsKind.cpp
+++ b/lib/AST/SelectorLocationsKind.cpp
@@ -54,8 +54,11 @@
template <>
SourceLocation getArgLoc<ParmVarDecl>(ParmVarDecl *Arg) {
+ SourceLocation Loc = Arg->getLocStart();
+ if (Loc.isInvalid())
+ return Loc;
// -1 to point to left paren of the method parameter's type.
- return Arg->getLocStart().getLocWithOffset(-1);
+ return Loc.getLocWithOffset(-1);
}
template <typename T>