Skip to content

Commit 1b2c13b

Browse files
authored
Merge pull request #75920 from ellishg/debug-info-verify
[IRGen][DebugInfo] Emit declarations for CFunctionPointer reps
2 parents 3df5e9c + c8a64e1 commit 1b2c13b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
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

58
// CHECK: define{{.*}}foo_static_method{{.*}} !dbg ![[FOO_STATIC_METHOD_DEF_DBG:[0-9]+]]
69
// CHECK: define{{.*}}foo_method{{.*}} !dbg ![[FOO_METHOD_DEF_DBG:[0-9]+]]
10+
// CHECK: define{{.*}}s1a3FooVACycfcyycfU_To{{.*}} !dbg ![[COMPILER_GEN_METHOD_DEF_DBG:[0-9]+]]
711
// CHECK: define{{.*}}bar_static_method{{.*}} !dbg ![[BAR_STATIC_METHOD_DEF_DBG:[0-9]+]]
812
// CHECK: define{{.*}}bar_method{{.*}} !dbg ![[BAR_METHOD_DEF_DBG:[0-9]+]]
913
// CHECK: define{{.*}}a_function{{.*}} !dbg ![[FUNC_DEF_DBG:[0-9]+]]
1014

15+
//--- a.swift
1116
// CHECK-DAG: ![[FOO_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Foo", {{.*}} identifier:
1217
public struct Foo {
1318
// 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 +21,11 @@ public struct Foo {
1621
// CHECK-DAG: ![[FOO_METHOD_DEF_DBG]] = distinct !DISubprogram(name: "foo_method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[FOO_METHOD_DECL_DBG:[0-9]+]]
1722
// CHECK-DAG: ![[FOO_METHOD_DECL_DBG]] = !DISubprogram(name: "foo_method"{{.*}}, scope: ![[FOO_DBG]]
1823
func foo_method() {}
24+
// CHECK-DAG: ![[COMPILER_GEN_METHOD_DEF_DBG]] = distinct !DISubprogram(linkageName: "$s1a3FooVACycfcyycfU_To"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[COMPILER_GEN_METHOD_DECL_DBG:[0-9]+]]
25+
// CHECK-DAG: ![[COMPILER_GEN_METHOD_DECL_DBG]] = !DISubprogram(linkageName: "$s1a3FooVACycfcyycfU_To"{{.*}}, scope: ![[FOO_DBG]]
26+
init() {
27+
let _ = ObjCGoo(myVal:{})
28+
}
1929
}
2030

2131
// CHECK-DAG: ![[BAR_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Bar", {{.*}} identifier:
@@ -35,3 +45,7 @@ public class Bar {
3545
// CHECK-SAME: )
3646
func a_function() {}
3747

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

0 commit comments

Comments
 (0)