r181629 - ObjC debug info: Substitute the class type for methods that return

Adrian Prantl aprantl at apple.com
Fri May 10 14:08:31 PDT 2013


Author: adrian
Date: Fri May 10 16:08:31 2013
New Revision: 181629

URL: http://llvm.org/viewvc/llvm-project?rev=181629&view=rev
Log:
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

Added:
    cfe/trunk/test/CodeGenObjC/debug-info-instancetype.m
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=181629&r1=181628&r2=181629&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri May 10 16:08:31 2013
@@ -2154,7 +2154,10 @@ llvm::DIType CGDebugInfo::getOrCreateFun
     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);

Added: cfe/trunk/test/CodeGenObjC/debug-info-instancetype.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-instancetype.m?rev=181629&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-instancetype.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-info-instancetype.m Fri May 10 16:08:31 2013
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+// rdar://problem/13359718
+// Substitute the actual type for a method returning instancetype.
+ at interface NSObject
++ (id)alloc;
+- (id)init;
+- (id)retain;
+ at end
+
+ at interface Foo : NSObject
++ (instancetype)defaultFoo;
+ at end
+
+ at implementation Foo
++(instancetype)defaultFoo {return 0;}
+// CHECK: ![[FOO:[0-9]+]] = metadata {{.*}}; [ DW_TAG_structure_type ] [Foo]
+// CHECK: metadata !"+[Foo defaultFoo]", metadata !"", i32 [[@LINE-2]], metadata ![[TYPE:[0-9]+]]
+// CHECK: ![[TYPE]] = {{.*}} metadata ![[RESULT:[0-9]+]], i32 {{.*}}, i32 {{.*}}} ; [ DW_TAG_subroutine_type ]
+// CHECK: ![[RESULT]] = metadata !{metadata ![[FOO]],
+ at end
+
+
+int main (int argc, const char *argv[])
+{
+  Foo *foo = [Foo defaultFoo];
+  return 0;
+}





More information about the cfe-commits mailing list