File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,21 @@ public final class Module: CustomStringConvertible {
148148 }
149149 }
150150
151+ /// Links the given module with this module. If the link succeeds, this
152+ /// module will the composite of the two input modules.
153+ ///
154+ /// The result of this function is `true` if the link succeeds, or `false`
155+ /// otherwise - unlike `llvm::Linker::linkModules`.
156+ ///
157+ /// - parameter other: The module to link with this module.
158+ public func link( _ other: Module ) -> Bool {
159+ // First clone the other module; `LLVMLinkModules2` consumes the source
160+ // module via a move and that module still owns its ModuleRef.
161+ let otherClone = LLVMCloneModule ( other. llvm)
162+ // N.B. Returns `true` on error.
163+ return LLVMLinkModules2 ( self . llvm, otherClone) == 0
164+ }
165+
151166 /// Retrieves the sequence of functions that make up this module.
152167 public var functions : AnySequence < Function > {
153168 var current = firstFunction
You can’t perform that action at this time.
0 commit comments