Skip to content

Detect methods by their scope rather than their representation. #72197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2868,9 +2868,7 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
// Because there's no good way to cross the CU boundary to insert a nested
// DISubprogram definition in one CU into a type defined in another CU when
// doing LTO builds.
if (Rep == SILFunctionTypeRepresentation::Method ||
Rep == SILFunctionTypeRepresentation::ObjCMethod ||
Rep == SILFunctionTypeRepresentation::WitnessMethod) {
if (llvm::isa<llvm::DICompositeType>(Scope)) {
llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::toSPFlags(
/*IsLocalToUnit=*/Fn ? Fn->hasInternalLinkage() : true,
/*IsDefinition=*/false, /*IsOptimized=*/Opts.shouldOptimize());
Expand Down
16 changes: 16 additions & 0 deletions test/DebugInfo/scope-method.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name a -g %s -o - | %FileCheck %s
public struct S {
public func f() {}
}

// CHECK-DAG: distinct !DISubprogram(name: "f", linkageName: "$s1a1SV1fyyF", scope: ![[STRUCT:[0-9]+]], {{.*}}declaration: ![[SDECL:[0-9]+]]
// CHECK-DAG: ![[SDECL]] = !DISubprogram(name: "f", linkageName: "$s1a1SV1fyyF", scope: ![[STRUCT]]
// CHECK-DAG: ![[STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "S"

public class C {
public func f() {}
}

// CHECK-DAG: distinct !DISubprogram(name: "f", linkageName: "$s1a1CC1fyyF", scope: ![[CLASS:[0-9]+]], {{.*}}declaration: ![[CDECL:[0-9]+]]
// CHECK-DAG: ![[CDECL]] = !DISubprogram(name: "f", linkageName: "$s1a1CC1fyyF", scope: ![[CLASS]]
// CHECK-DAG: ![[CLASS]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C"