Skip to content

Pass valid count pointer to LLVMGetModuleIdentifier #171

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 2 commits into from
Dec 23, 2018
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
3 changes: 2 additions & 1 deletion Sources/LLVM/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public final class Module: CustomStringConvertible {
/// The identifier of this module.
public var name: String {
get {
guard let id = LLVMGetModuleIdentifier(llvm, nil) else { return "" }
var count = 0
guard let id = LLVMGetModuleIdentifier(llvm, &count) else { return "" }
return String(cString: id)
}
set {
Expand Down
2 changes: 2 additions & 0 deletions Tests/LLVMTests/ModuleLinkSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ModuleLinkSpec : XCTestCase {
// MODULE-LINK: ; ModuleID = '[[ModuleName1:ModuleLinkModuleOne]]'
// MODULE-LINK-NEXT: source_filename = "[[ModuleName1]]"
let module1 = Module(name: "ModuleLinkModuleOne")
XCTAssertEqual(module1.name, "ModuleLinkModuleOne")
let builder1 = IRBuilder(module: module1)
// MODULE-LINK: define void @moduleOne() {
let mod1f = builder1.addFunction("moduleOne",
Expand All @@ -25,6 +26,7 @@ class ModuleLinkSpec : XCTestCase {
// MODULE-LINK: ; ModuleID = '[[ModuleName2:ModuleLinkModuleTwo]]'
// MODULE-LINK-NEXT: source_filename = "[[ModuleName2]]"
let module2 = Module(name: "ModuleLinkModuleTwo")
XCTAssertEqual(module2.name, "ModuleLinkModuleTwo")
let builder2 = IRBuilder(module: module2)
// MODULE-LINK: define void @moduleTwo() {
let mod2f = builder2.addFunction("moduleTwo",
Expand Down