Skip to content

Commit 7c19ca2

Browse files
committed
[IRGen][DebugInfo] Emit declarations for CFunctionPointer reps
1 parent 795bfb9 commit 7c19ca2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,6 +2971,7 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
29712971
Rep == SILFunctionTypeRepresentation::ObjCMethod ||
29722972
Rep == SILFunctionTypeRepresentation::WitnessMethod ||
29732973
Rep == SILFunctionTypeRepresentation::CXXMethod ||
2974+
Rep == SILFunctionTypeRepresentation::CFunctionPointer ||
29742975
Rep == SILFunctionTypeRepresentation::Thin)) {
29752976
llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::toSPFlags(
29762977
/*IsLocalToUnit=*/Fn ? Fn->hasInternalLinkage() : true,

test/DebugInfo/method-declaration.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// RUN: %target-swift-frontend -primary-file %s -emit-ir -gdwarf-types -o - | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -primary-file %t/a.swift -import-objc-header %t/objc.h -enable-objc-interop -emit-ir -gdwarf-types -o - | %FileCheck %s
25

36
// Verify that we added a declaration for a method.
47

@@ -8,6 +11,7 @@
811
// CHECK: define{{.*}}bar_method{{.*}} !dbg ![[BAR_METHOD_DEF_DBG:[0-9]+]]
912
// CHECK: define{{.*}}a_function{{.*}} !dbg ![[FUNC_DEF_DBG:[0-9]+]]
1013

14+
//--- a.swift
1115
// CHECK-DAG: ![[FOO_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Foo", {{.*}} identifier:
1216
public struct Foo {
1317
// CHECK-DAG: ![[FOO_STATIC_METHOD_DEF_DBG]] = distinct !DISubprogram(name: "foo_static_method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[FOO_STATIC_METHOD_DECL_DBG:[0-9]+]]
@@ -16,6 +20,13 @@ public struct Foo {
1620
// CHECK-DAG: ![[FOO_METHOD_DEF_DBG]] = distinct !DISubprogram(name: "foo_method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[FOO_METHOD_DECL_DBG:[0-9]+]]
1721
// CHECK-DAG: ![[FOO_METHOD_DECL_DBG]] = !DISubprogram(name: "foo_method"{{.*}}, scope: ![[FOO_DBG]]
1822
func foo_method() {}
23+
24+
// CHECK-DAG: !DISubprogram(linkageName: "$s1a3FooVACycfcyycfU_To"
25+
// CHECK-SAME: scope: ![[FOO_DBG]]
26+
// CHECK-SAME: declaration: !
27+
init() {
28+
let _ = ObjCGoo(myVal:{})
29+
}
1930
}
2031

2132
// CHECK-DAG: ![[BAR_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Bar", {{.*}} identifier:
@@ -35,3 +46,7 @@ public class Bar {
3546
// CHECK-SAME: )
3647
func a_function() {}
3748

49+
//--- objc.h
50+
@interface ObjCGoo
51+
- (instancetype)initWithMyVal:(void (*)())myVal;
52+
@end

0 commit comments

Comments
 (0)