Skip to content

Commit 9561624

Browse files
authored
Merge pull request #151 from maleadt/tb/flags_setindex
Use setindex for setting module flags.
2 parents c478a89 + b209301 commit 9561624

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/core/module.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ function Base.getindex(iter::ModuleFlagDict, name::String)
200200
return Metadata(objref)
201201
end
202202

203-
Base.push!(iter::ModuleFlagDict, behavior::LLVM.API.LLVMModuleFlagBehavior, name::String, val::Metadata) =
203+
function Base.setindex!(iter::ModuleFlagDict, val::Metadata,
204+
(name, behavior)::Tuple{String, LLVM.API.LLVMModuleFlagBehavior})
204205
API.LLVMAddModuleFlag(ref(iter.mod), behavior, name, length(name), ref(val))
206+
end
205207

206208
end

test/core.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ LLVM.Module("SomeModule", ctx) do mod
533533
md = Metadata(ConstantInt(42, ctx))
534534

535535
mod_flags = flags(mod)
536-
push!(mod_flags, LLVM.API.LLVMModuleFlagBehaviorError, "foobar", md)
536+
mod_flags["foobar", LLVM.API.LLVMModuleFlagBehaviorError] = md
537537

538538
@test occursin("!llvm.module.flags = !{!0}", sprint(io->show(io,mod)))
539539
@test occursin(r"!0 = !\{i\d+ 1, !\"foobar\", i\d+ 42\}", sprint(io->show(io,mod)))

0 commit comments

Comments
 (0)