]> granicus.if.org Git - clang/commitdiff
List objective-c ineterfaces as public types in dwarf debug info output.
authorDevang Patel <dpatel@apple.com>
Tue, 31 May 2011 21:18:50 +0000 (21:18 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 31 May 2011 21:18:50 +0000 (21:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132361 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenObjC/debug-info-pubtypes.m [new file with mode: 0644]

index d1b4aad7fa8960e2aae2d8515d5d15e32816739f..5ebf133303efa735283ff4bdf6c651c1e690209e 100644 (file)
@@ -1627,7 +1627,29 @@ llvm::DIType CGDebugInfo::getOrCreateFunctionType(const Decl * D, QualType FnTyp
                                                   llvm::DIFile F) {
   if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
     return getOrCreateMethodType(Method, F);
+  else if (const ObjCMethodDecl *OMethod = dyn_cast<ObjCMethodDecl>(D)) {
 
+    llvm::DIType MTy = getOrCreateType(FnType, F);
+    llvm::DIArray Args = llvm::DICompositeType(MTy).getTypeArray();
+    assert (Args.getNumElements() && "Invalid number of arguments!");
+
+    // Add "self" and "_cmd"
+    llvm::SmallVector<llvm::Value *, 16> Elts;
+
+    // First element is always return type. For 'void' functions it is NULL.
+    Elts.push_back(Args.getElement(0));
+
+    // "self" pointer is always first argument.
+    Elts.push_back(getOrCreateType(OMethod->getSelfDecl()->getType(), F));
+    // "cmd" pointer is always second argument.
+    Elts.push_back(getOrCreateType(OMethod->getCmdDecl()->getType(), F));
+    
+    // Copy rest of the arguments.
+    for (unsigned i = 1, e = Args.getNumElements(); i != e; ++i)
+      Elts.push_back(Args.getElement(i));
+    llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
+    return DBuilder.createSubroutineType(F, EltTypeArray);
+  }
   return getOrCreateType(FnType, F);
 }
 
diff --git a/test/CodeGenObjC/debug-info-pubtypes.m b/test/CodeGenObjC/debug-info-pubtypes.m
new file mode 100644 (file)
index 0000000..abbfe5c
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10  -g -S %s -o %t
+// RUN: FileCheck %s < %t
+
+//CHECK:        .long   Lset6
+//CHECK-NEXT:   .long   256
+//CHECK-NEXT:   .asciz   "H"
+//CHECK-NEXT:   .long   0
+//CHECK-NEXT:   Lpubtypes_end1:
+
+@interface H
+-(void) foo;
+@end
+
+@implementation H
+-(void) foo {
+}
+@end
+