Skip to content

Commit e24e47d

Browse files
committed
Apply swift naming conventions and update unavailable message
1 parent fabc297 commit e24e47d

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

Sources/LLVM/Constant.swift

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,12 @@ extension Constant where Repr == Floating {
142142

143143
extension Constant where Repr == Struct {
144144

145-
/// - note: See the LLVM Reference manual's section on `bitcast`
146-
@available(*, unavailable, message: "You cannot cast an aggregate type")
145+
@available(*, unavailable, message: "You cannot cast an aggregate type. See the LLVM Reference manual's section on `bitcast`")
147146
public func cast<T: IntegralConstantRepresentation>(to type: IntType) -> Constant<T> {
148147
fatalError()
149148
}
150149

151-
/// - note: See the LLVM Reference manual's section on `bitcast`
152-
@available(*, unavailable, message: "You cannot cast an aggregate type")
150+
@available(*, unavailable, message: "You cannot cast an aggregate type. See the LLVM Reference manual's section on `bitcast`")
153151
public func cast(to type: FloatType) -> Constant<Floating> {
154152
fatalError()
155153
}
@@ -278,7 +276,7 @@ extension Constant where Repr == Signed {
278276
/// behavior of the resulting constant value.
279277
///
280278
/// - returns: A constant value representing the sum of the two operands.
281-
public func add(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
279+
public func adding(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
282280
return Constant.add(self, rhs, overflowBehavior: overflowBehavior)
283281
}
284282
}
@@ -292,7 +290,7 @@ extension Constant where Repr == Unsigned {
292290
/// behavior of the resulting constant value.
293291
///
294292
/// - returns: A constant value representing the sum of the two operands.
295-
public func add(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
293+
public func adding(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
296294
return Constant.add(self, rhs, overflowBehavior: overflowBehavior)
297295
}
298296
}
@@ -304,7 +302,7 @@ extension Constant where Repr == Floating {
304302
/// - parameter rhs: The second summand value (the addend).
305303
///
306304
/// - returns: A constant value representing the sum of the two operands.
307-
public func add(_ rhs: Constant) -> Constant {
305+
public func adding(_ rhs: Constant) -> Constant {
308306
return Constant.add(self, rhs)
309307
}
310308
}
@@ -373,7 +371,7 @@ extension Constant where Repr == Unsigned {
373371
/// behavior of the resulting constant value.
374372
///
375373
/// - returns: A constant value representing the difference of the two operands.
376-
public func subtract(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
374+
public func subtracting(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
377375
return Constant.subtract(self, rhs, overflowBehavior: overflowBehavior)
378376
}
379377
}
@@ -387,7 +385,7 @@ extension Constant where Repr == Signed {
387385
/// behavior of the resulting constant value.
388386
///
389387
/// - returns: A constant value representing the difference of the two operands.
390-
public func subtract(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
388+
public func subtracting(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
391389
return Constant.subtract(self, rhs, overflowBehavior: overflowBehavior)
392390
}
393391
}
@@ -399,7 +397,7 @@ extension Constant where Repr == Floating {
399397
/// - parameter rhs: The second value (the subtrahend).
400398
///
401399
/// - returns: A constant value representing the difference of the two operands.
402-
public func subtract(_ rhs: Constant) -> Constant {
400+
public func subtracting(_ rhs: Constant) -> Constant {
403401
return Constant.subtract(self, rhs)
404402
}
405403
}
@@ -468,7 +466,7 @@ extension Constant where Repr == Unsigned {
468466
/// behavior of the resulting constant value.
469467
///
470468
/// - returns: A constant value representing the product of the two operands.
471-
public func multiply(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
469+
public func multiplying(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
472470
return Constant.multiply(self, rhs, overflowBehavior: overflowBehavior)
473471
}
474472
}
@@ -482,7 +480,7 @@ extension Constant where Repr == Signed {
482480
/// behavior of the resulting constant value.
483481
///
484482
/// - returns: A constant value representing the product of the two operands.
485-
public func multiply(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
483+
public func multiplying(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant {
486484
return Constant.multiply(self, rhs, overflowBehavior: overflowBehavior)
487485
}
488486
}
@@ -495,7 +493,7 @@ extension Constant where Repr == Floating {
495493
/// - parameter rhs: The second factor value (the multiplicand).
496494
///
497495
/// - returns: A constant value representing the product of the two operands.
498-
public func multiply(_ rhs: Constant) -> Constant {
496+
public func multiplying(_ rhs: Constant) -> Constant {
499497
return Constant.multiply(self, rhs)
500498
}
501499
}
@@ -550,7 +548,7 @@ extension Constant where Repr == Unsigned {
550548
///
551549
/// - returns: A constant value representing the quotient of the first and
552550
/// second operands.
553-
public func divide(_ rhs: Constant) -> Constant {
551+
public func dividing(_ rhs: Constant) -> Constant {
554552
return Constant.divide(self, rhs)
555553
}
556554
}
@@ -564,7 +562,7 @@ extension Constant where Repr == Signed {
564562
///
565563
/// - returns: A constant value representing the quotient of the first and
566564
/// second operands.
567-
public func divide(_ rhs: Constant) -> Constant {
565+
public func dividing(_ rhs: Constant) -> Constant {
568566
return Constant.divide(self, rhs)
569567
}
570568
}
@@ -578,7 +576,7 @@ extension Constant where Repr == Floating {
578576
///
579577
/// - returns: A constant value representing the quotient of the first and
580578
/// second operands.
581-
public func divide(_ rhs: Constant) -> Constant {
579+
public func dividing(_ rhs: Constant) -> Constant {
582580
return Constant.divide(self, rhs)
583581
}
584582
}

Tests/LLVMTests/ConstantSpec.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class ConstantSpec : XCTestCase {
2020
builder.positionAtEnd(of: entry)
2121

2222
// SIGNEDCONST-NOT: %{{[0-9]+}} = add i64 %%{{[0-9]+}}, %%{{[0-9]+}}
23-
let val1 = builder.buildAdd(constant.add(constant), constant.multiply(constant))
23+
let val1 = builder.buildAdd(constant.adding(constant), constant.multiplying(constant))
2424
// SIGNEDCONST-NOT: %{{[0-9]+}} = sub i64 %%{{[0-9]+}}, %%{{[0-9]+}}
25-
let val2 = builder.buildSub(constant.subtract(constant), constant.divide(constant))
25+
let val2 = builder.buildSub(constant.subtracting(constant), constant.dividing(constant))
2626
// SIGNEDCONST-NOT: %{{[0-9]+}} = mul i64 %%{{[0-9]+}}, %%{{[0-9]+}}
2727
let val3 = builder.buildMul(val1, val2)
2828
// SIGNEDCONST-NOT: %{{[0-9]+}} = mul i64 %%{{[0-9]+}}, %%{{[0-9]+}}
@@ -50,9 +50,9 @@ class ConstantSpec : XCTestCase {
5050
builder.positionAtEnd(of: entry)
5151

5252
// UNSIGNEDCONST-NOT: %{{[0-9]+}} = add i64 %%{{[0-9]+}}, %%{{[0-9]+}}
53-
let val1 = builder.buildAdd(constant.add(constant), constant.multiply(constant))
53+
let val1 = builder.buildAdd(constant.adding(constant), constant.multiplying(constant))
5454
// UNSIGNEDCONST-NOT: %{{[0-9]+}} = sub i64 %%{{[0-9]+}}, %%{{[0-9]+}}
55-
let val2 = builder.buildSub(constant.subtract(constant), constant.divide(constant))
55+
let val2 = builder.buildSub(constant.subtracting(constant), constant.dividing(constant))
5656
// UNSIGNEDCONST-NOT: %{{[0-9]+}} = mul i64 %%{{[0-9]+}}, %%{{[0-9]+}}
5757
let val3 = builder.buildMul(val1, val2)
5858

@@ -78,9 +78,9 @@ class ConstantSpec : XCTestCase {
7878
builder.positionAtEnd(of: entry)
7979

8080
// FLOATINGCONST-NOT: %{{[0-9]+}} = add double %%{{[0-9]+}}, %%{{[0-9]+}}
81-
let val1 = builder.buildAdd(constant.add(constant), constant.multiply(constant))
81+
let val1 = builder.buildAdd(constant.adding(constant), constant.multiplying(constant))
8282
// FLOATINGCONST-NOT: %{{[0-9]+}} = sub double %%{{[0-9]+}}, %%{{[0-9]+}}
83-
let val2 = builder.buildSub(constant.subtract(constant), constant.divide(constant))
83+
let val2 = builder.buildSub(constant.subtracting(constant), constant.dividing(constant))
8484
// FLOATINGCONST-NOT: %{{[0-9]+}} = mul double %%{{[0-9]+}}, %%{{[0-9]+}}
8585
let val3 = builder.buildMul(val1, val2)
8686

0 commit comments

Comments
 (0)