Modern objc translator: Fixes a crash in rewriter when rewriting the API
for structure valued method messaging. // rdar://12142241


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162303 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/RewriteModernObjC.cpp b/lib/Rewrite/RewriteModernObjC.cpp
index dcd003f..9c98a7f 100644
--- a/lib/Rewrite/RewriteModernObjC.cpp
+++ b/lib/Rewrite/RewriteModernObjC.cpp
@@ -3140,7 +3140,14 @@
   str += "\t"; str += returnType.getAsString(Context->getPrintingPolicy());
   str += " s;\n";
   str += "};\n\n";
-  SourceLocation FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
+  SourceLocation FunLocStart;
+  if (CurFunctionDef)
+    FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
+  else {
+    assert(CurMethodDef && "SynthMsgSendStretCallExpr - CurMethodDef is null");
+    FunLocStart = CurMethodDef->getLocStart();
+  }
+
   InsertText(FunLocStart, str);
   ++stretCount;