Skip to content

Commit 28b1b9c

Browse files
committed
Support querying an unnamed struct's name.
1 parent 1c32b3e commit 28b1b9c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/core/type.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ end
193193
StructType(elems::Vector{<:LLVMType}; packed::Core.Bool=false, ctx::Context) =
194194
StructType(API.LLVMStructTypeInContext(ctx, elems, length(elems), convert(Bool, packed)))
195195

196-
name(structtyp::StructType) =
197-
unsafe_string(API.LLVMGetStructName(structtyp))
196+
function name(structtyp::StructType)
197+
cstr = API.LLVMGetStructName(structtyp)
198+
cstr == C_NULL ? nothing : unsafe_string(cstr)
199+
end
198200
ispacked(structtyp::StructType) =
199201
convert(Core.Bool, API.LLVMIsPackedStruct(structtyp))
200202
isopaque(structtyp::StructType) =

test/core.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ end
122122
@test context(st) == ctx
123123
@test !ispacked(st)
124124
@test !isopaque(st)
125+
@test name(st) === nothing
125126

126127
let elem_it = elements(st)
127128
@test eltype(elem_it) == LLVMType

0 commit comments

Comments
 (0)