Skip to content

Commit 8e5ea03

Browse files
authored
Debug info: Export subprogram getter and setter. (#472)
1 parent 093469a commit 8e5ea03

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/debuginfo.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ register(DICompileUnit, API.LLVMDICompileUnitMetadataKind)
161161

162162
## other
163163

164-
export DEBUG_METADATA_VERSION, strip_debuginfo!
164+
export DEBUG_METADATA_VERSION, strip_debuginfo!, subprogram, subprogram!
165165

166166
DEBUG_METADATA_VERSION() = API.LLVMDebugMetadataVersion()
167167

168168
strip_debuginfo!(mod::Module) = API.LLVMStripModuleDebugInfo(mod)
169169

170-
function get_subprogram(func::Function)
170+
function subprogram(func::Function)
171171
ref = API.LLVMGetSubprogram(func)
172172
ref==C_NULL ? nothing : Metadata(ref)::DISubProgram
173173
end
174-
set_subprogram!(func::Function, sp::DISubProgram) = API.LLVMSetSubprogram(func, sp)
174+
subprogram!(func::Function, sp::DISubProgram) = API.LLVMSetSubprogram(func, sp)

src/deprecated.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ function Base.show(io::IO, ::MIME"text/plain", md::MDString)
4141
str = @invoke string(md::Metadata)
4242
print(io, strip(str))
4343
end
44+
45+
@deprecate get_subprogram(func::Function) subprogram(func) false
46+
@deprecate set_subprogram!(func::Function, sp::DISubProgram) subprogram!(func, sp) false

test/debuginfo_tests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ DEBUG_METADATA_VERSION()
4747

4848
foo = functions(mod)["foo"]
4949

50-
let sp = LLVM.get_subprogram(foo)
50+
let sp = subprogram(foo)
5151
@test sp !== nothing
5252
@test LLVM.line(sp) == 1
5353

5454
bar = functions(mod)["bar"]
55-
@test LLVM.get_subprogram(bar) === nothing
56-
LLVM.set_subprogram!(bar, sp)
57-
@test LLVM.get_subprogram(bar) == sp
55+
@test subprogram(bar) === nothing
56+
subprogram!(bar, sp)
57+
@test subprogram(bar) == sp
5858
end
5959

6060
bb = entry(foo)

0 commit comments

Comments
 (0)