Skip to content

Commit 37071f1

Browse files
committed
Add missing docs
1 parent bd42124 commit 37071f1

10 files changed

+68
-2
lines changed

Sources/LLVM/Arbitrary.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import cllvm
1212
/// supports both the typical integer arithmetic and comparison operations as
1313
/// well as bitwise manipulation.
1414
public struct APInt: IRConstant {
15+
/// The underlying word size.
1516
public typealias Word = UInt64
1617

1718
private enum Impl {
@@ -20,6 +21,8 @@ public struct APInt: IRConstant {
2021
}
2122

2223
private var value: Impl
24+
25+
/// The bitwidth of this integer.
2326
public private(set) var bitWidth: Int
2427

2528
fileprivate init(raw values: [Word], _ bits: Int) {
@@ -166,12 +169,16 @@ extension APInt: Numeric {
166169
self.init(integerLiteral: val)
167170
}
168171

172+
/// Returns the result of performing a bitwise AND operation on the two
173+
/// given values.
169174
public static func & (lhs: APInt, rhs: APInt) -> APInt {
170175
var lhs = lhs
171176
lhs &= rhs
172177
return lhs
173178
}
174179

180+
/// Stores the result of performing a bitwise AND operation on the two given
181+
/// values in the left-hand-side variable.
175182
public static func &= (lhs: inout APInt, rhs: APInt) {
176183
precondition(lhs.bitWidth == rhs.bitWidth)
177184
switch (lhs.value, rhs.value) {
@@ -188,12 +195,16 @@ extension APInt: Numeric {
188195
}
189196
}
190197

198+
/// Returns the result of performing a bitwise OR operation on the two
199+
/// given values.
191200
public static func | (lhs: APInt, rhs: APInt) -> APInt {
192201
var lhs = lhs
193202
lhs |= rhs
194203
return lhs
195204
}
196205

206+
/// Stores the result of performing a bitwise OR operation on the two given
207+
/// values in the left-hand-side variable.
197208
public static func |= (lhs: inout APInt, rhs: APInt) {
198209
precondition(lhs.bitWidth == rhs.bitWidth)
199210
switch (lhs.value, rhs.value) {
@@ -210,12 +221,16 @@ extension APInt: Numeric {
210221
}
211222
}
212223

224+
/// Returns the result of performing a bitwise XOR operation on the two
225+
/// given values.
213226
public static func ^ (lhs: APInt, rhs: APInt) -> APInt {
214227
var lhs = lhs
215228
lhs ^= rhs
216229
return lhs
217230
}
218231

232+
/// Stores the result of performing a bitwise XOR operation on the two given
233+
/// values in the left-hand-side variable.
219234
public static func ^= (lhs: inout APInt, rhs: APInt) {
220235
precondition(lhs.bitWidth == rhs.bitWidth)
221236
switch (lhs.value, rhs.value) {
@@ -388,12 +403,16 @@ extension APInt: Numeric {
388403
}
389404
}
390405

406+
/// Returns the result of shifting a value’s binary representation the
407+
/// specified number of digits to the left.
391408
public static func << (lhs: APInt, amount: UInt64) -> APInt {
392409
var lhs = lhs
393410
lhs <<= amount
394411
return lhs
395412
}
396413

414+
/// Stores the result of shifting a value’s binary representation the
415+
/// specified number of digits to the left in the left-hand-side variable.
397416
public static func <<= (lhs: inout APInt, amount: UInt64) {
398417
precondition(amount <= lhs.bitWidth)
399418
switch lhs.value {

Sources/LLVM/AttachedMetadata.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ public class AttachedMetadata {
685685
self.bounds = bounds
686686
}
687687

688+
/// Deinitialize this value and dispose of its resources.
688689
deinit {
689690
guard let ptr = llvm else { return }
690691
LLVMDisposeValueMetadataEntries(ptr)
@@ -700,6 +701,7 @@ public class AttachedMetadata {
700701
return Entry(base: self, index: UInt32(index))
701702
}
702703

704+
/// Returns the number of metadata entries.
703705
public var count: Int {
704706
return self.bounds
705707
}

Sources/LLVM/DIBuilder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public final class DIBuilder {
3232
LLVMDIBuilderFinalize(self.llvm)
3333
}
3434

35+
/// Deinitialize this value and dispose of its resources.
3536
deinit {
3637
LLVMDisposeDIBuilder(self.llvm)
3738
}

Sources/LLVM/IRBuilder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class IRBuilder {
1919
self.llvm = LLVMCreateBuilderInContext(module.context.llvm)
2020
}
2121

22+
/// Deinitialize this value and dispose of its resources.
2223
deinit {
2324
LLVMDisposeBuilder(llvm)
2425
}

Sources/LLVM/IRMetadata.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,36 +385,67 @@ public struct ExpressionMetadata: IRMetadata {
385385

386386
/// Enumerates the kind of metadata nodes.
387387
public enum IRMetadataKind {
388+
/// The metadata is a string.
388389
case mdString
390+
/// The metadata is a constant-as-metadata node.
389391
case constantAsMetadata
392+
/// The metadata is a local-as-metadata node.
390393
case localAsMetadata
394+
/// The metadata is a disctint metadata operand placeholder.
391395
case distinctMDOperandPlaceholder
396+
/// The metadata is a tuple.
392397
case mdTuple
398+
/// The metadata is a location.
393399
case location
400+
/// The metadata is an expression.
394401
case expression
402+
/// The metadata is a global variable expression.
395403
case globalVariableExpression
404+
/// The metadata is a generic DI node.
396405
case genericDINode
406+
/// The metadata is a subrange.
397407
case subrange
408+
/// The metadata is an enumerator.
398409
case enumerator
410+
/// The metadata is a basic type.
399411
case basicType
412+
/// The metadata is a derived type.
400413
case derivedType
414+
/// The metadata is a composite type.
401415
case compositeType
416+
/// The metadata is a subroutine type.
402417
case subroutineType
418+
/// The metadata is a file.
403419
case file
420+
/// The metadata is a compile unit.
404421
case compileUnit
422+
/// The metadata is a subprogram.
405423
case subprogram
424+
/// The metadata is a lexical block.
406425
case lexicalBlock
426+
/// The metadata is a lexical block file.
407427
case lexicalBlockFile
428+
/// The metadata is a namespace.
408429
case namespace
430+
/// The metadata is a module.
409431
case module
432+
/// The metadata is a template type parameter.
410433
case templateTypeParameter
434+
/// The metadata is a template value parameter.
411435
case templateValueParameter
436+
/// The metadata is a global variable.
412437
case globalVariable
438+
/// The metadata is a local variable.
413439
case localVariable
440+
/// The metadata is a label.
414441
case label
442+
/// The metadata is an Objective-C property.
415443
case objCProperty
444+
/// The metadata is an imported entity.
416445
case importedEntity
446+
/// The metadata is a macro.
417447
case macro
448+
/// The metadata is a macro file.
418449
case macroFile
419450

420451
fileprivate init(raw: LLVMMetadataKind) {

Sources/LLVM/JIT.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public final class JIT {
7272
self.init(llvm: LLVMOrcCreateInstance(machine.llvm), ownsContext: true)
7373
}
7474

75+
/// Deinitialize this value and dispose of its resources.
7576
deinit {
7677
guard self.ownsContext else {
7778
return

Sources/LLVM/MemoryBuffer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public class MemoryBuffer: Sequence {
115115
return UnsafeBufferPointer(start: start, count: size).makeIterator()
116116
}
117117

118+
/// Deinitialize this value and dispose of its resources.
118119
deinit {
119120
guard self.ownsContext else {
120121
return

Sources/LLVM/Module.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ public class Context {
3232
set { LLVMContextSetDiscardValueNames(self.llvm, newValue.llvm) }
3333
}
3434

35+
/// Deinitialize this value and dispose of its resources.
3536
deinit {
36-
if ownsContext {
37-
LLVMContextDispose(llvm)
37+
guard self.ownsContext else {
38+
return
3839
}
40+
LLVMContextDispose(self.llvm)
3941
}
4042
}
4143

@@ -329,6 +331,7 @@ public final class Module: CustomStringConvertible {
329331
return String(cString: cStr)
330332
}
331333

334+
/// Deinitialize this value and dispose of its resources.
332335
deinit {
333336
guard self.ownsContext else {
334337
return
@@ -587,6 +590,7 @@ extension Module {
587590
self.bounds = bounds
588591
}
589592

593+
/// Deinitialize this value and dispose of its resources.
590594
deinit {
591595
guard let ptr = llvm else { return }
592596
LLVMDisposeModuleFlagsMetadata(ptr)
@@ -602,6 +606,7 @@ extension Module {
602606
return Entry(base: self, index: UInt32(index))
603607
}
604608

609+
/// Returns the number of module flag metadata entries.
605610
public var count: Int {
606611
return self.bounds
607612
}

Sources/LLVM/ObjectFile.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class ObjectFile {
3737
return SymbolSequence(llvm: LLVMGetSymbols(llvm), object: self)
3838
}
3939

40+
/// Deinitialize this value and dispose of its resources.
4041
deinit {
4142
LLVMDisposeObjectFile(llvm)
4243
}
@@ -100,6 +101,7 @@ public class SectionSequence: Sequence {
100101
}
101102
}
102103

104+
/// Deinitialize this value and dispose of its resources.
103105
deinit {
104106
LLVMDisposeSectionIterator(llvm)
105107
}
@@ -171,6 +173,7 @@ public class RelocationSequence: Sequence {
171173
}
172174
}
173175

176+
/// Deinitialize this value and dispose of its resources.
174177
deinit {
175178
LLVMDisposeSectionIterator(llvm)
176179
}
@@ -198,6 +201,7 @@ public class SymbolSequence: Sequence {
198201
}
199202
}
200203

204+
/// Deinitialize this value and dispose of its resources.
201205
deinit {
202206
LLVMDisposeSymbolIterator(llvm)
203207
}

Sources/LLVM/TargetMachine.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ public class TargetMachine {
273273
return MemoryBuffer(llvm: llvm)
274274
}
275275

276+
/// Deinitialize this value and dispose of its resources.
276277
deinit {
277278
guard self.ownsContext else {
278279
return

0 commit comments

Comments
 (0)