ObjC debug info: Substitute the class type for methods that return
a related type (e.g., if they use the instancetype keyword).

rdar://problem/13359718

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181629 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 6678aa7..d9ab090 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -2154,7 +2154,10 @@
     SmallVector<llvm::Value *, 16> Elts;
 
     // First element is always return type. For 'void' functions it is NULL.
-    Elts.push_back(getOrCreateType(OMethod->getResultType(), F));
+    QualType ResultTy = OMethod->hasRelatedResultType()
+      ? QualType(OMethod->getClassInterface()->getTypeForDecl(), 0)
+      : OMethod->getResultType();
+    Elts.push_back(getOrCreateType(ResultTy, F));
     // "self" pointer is always first argument.
     QualType SelfDeclTy = OMethod->getSelfDecl()->getType();
     llvm::DIType SelfTy = getOrCreateType(SelfDeclTy, F);