Skip to content

Commit 7f5194b

Browse files
Merge pull request #72197 from adrian-prantl/better-scope-check
Detect methods by their scope rather than their representation.
2 parents 76e71e7 + 654df59 commit 7f5194b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,9 +2868,7 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
28682868
// Because there's no good way to cross the CU boundary to insert a nested
28692869
// DISubprogram definition in one CU into a type defined in another CU when
28702870
// doing LTO builds.
2871-
if (Rep == SILFunctionTypeRepresentation::Method ||
2872-
Rep == SILFunctionTypeRepresentation::ObjCMethod ||
2873-
Rep == SILFunctionTypeRepresentation::WitnessMethod) {
2871+
if (llvm::isa<llvm::DICompositeType>(Scope)) {
28742872
llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::toSPFlags(
28752873
/*IsLocalToUnit=*/Fn ? Fn->hasInternalLinkage() : true,
28762874
/*IsDefinition=*/false, /*IsOptimized=*/Opts.shouldOptimize());

test/DebugInfo/scope-method.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name a -g %s -o - | %FileCheck %s
2+
public struct S {
3+
public func f() {}
4+
}
5+
6+
// CHECK-DAG: distinct !DISubprogram(name: "f", linkageName: "$s1a1SV1fyyF", scope: ![[STRUCT:[0-9]+]], {{.*}}declaration: ![[SDECL:[0-9]+]]
7+
// CHECK-DAG: ![[SDECL]] = !DISubprogram(name: "f", linkageName: "$s1a1SV1fyyF", scope: ![[STRUCT]]
8+
// CHECK-DAG: ![[STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "S"
9+
10+
public class C {
11+
public func f() {}
12+
}
13+
14+
// CHECK-DAG: distinct !DISubprogram(name: "f", linkageName: "$s1a1CC1fyyF", scope: ![[CLASS:[0-9]+]], {{.*}}declaration: ![[CDECL:[0-9]+]]
15+
// CHECK-DAG: ![[CDECL]] = !DISubprogram(name: "f", linkageName: "$s1a1CC1fyyF", scope: ![[CLASS]]
16+
// CHECK-DAG: ![[CLASS]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C"

0 commit comments

Comments
 (0)