@@ -230,6 +230,29 @@ public final class Module: CustomStringConvertible {
230
230
}
231
231
}
232
232
233
+ /// Retrieves the sequence of aliases that make up this module.
234
+ public var aliases : AnySequence < Alias > {
235
+ var current = firstAlias
236
+ return AnySequence< Alias> {
237
+ return AnyIterator< Alias> {
238
+ defer { current = current? . next ( ) }
239
+ return current
240
+ }
241
+ }
242
+ }
243
+
244
+ /// Retrieves the first alias in this module, if there are any aliases.
245
+ public var firstAlias : Alias ? {
246
+ guard let fn = LLVMGetFirstGlobalAlias ( llvm) else { return nil }
247
+ return Alias ( llvm: fn)
248
+ }
249
+
250
+ /// Retrieves the last alias in this module, if there are any aliases.
251
+ public var lastAlias : Alias ? {
252
+ guard let fn = LLVMGetLastGlobalAlias ( llvm) else { return nil }
253
+ return Alias ( llvm: fn)
254
+ }
255
+
233
256
/// The current debug metadata version number.
234
257
public static var debugMetadataVersion : UInt32 {
235
258
return LLVMDebugMetadataVersion ( ) ;
@@ -307,6 +330,18 @@ extension Module {
307
330
return Function ( llvm: fn)
308
331
}
309
332
333
+ /// Searches for and retrieves an alias with the given name in this module
334
+ /// if that name references an existing alias.
335
+ ///
336
+ /// - parameter name: The name of the alias to search for.
337
+ ///
338
+ /// - returns: A representation of an alias with the given
339
+ /// name or nil if no such named alias exists.
340
+ public func alias( named name: String ) -> Alias ? {
341
+ guard let alias = LLVMGetNamedGlobalAlias ( llvm, name, name. count) else { return nil }
342
+ return Alias ( llvm: alias)
343
+ }
344
+
310
345
/// Searches for and retrieves a comdat section with the given name in this
311
346
/// module. If none is found, one with that name is created and returned.
312
347
///
0 commit comments