Skip to content

Commit 5e2e7e3

Browse files
committed
SIL Bridging: use bool for boolean properties
This was a leftover from the time we didn't use C++ interop
1 parent 9326da0 commit 5e2e7e3

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ final public class CopyAddrInst : Instruction {
236236
public var destination: Value { return destinationOperand.value }
237237

238238
public var isTakeOfSrc: Bool {
239-
bridged.CopyAddrInst_isTakeOfSrc() != 0
239+
bridged.CopyAddrInst_isTakeOfSrc()
240240
}
241241
public var isInitializationOfDest: Bool {
242-
bridged.CopyAddrInst_isInitializationOfDest() != 0
242+
bridged.CopyAddrInst_isInitializationOfDest()
243243
}
244244
}
245245

@@ -534,7 +534,7 @@ final public class RefElementAddrInst : SingleValueInstruction, UnaryInstruction
534534
public var instance: Value { operand.value }
535535
public var fieldIndex: Int { bridged.RefElementAddrInst_fieldIndex() }
536536

537-
public var fieldIsLet: Bool { bridged.RefElementAddrInst_fieldIsLet() != 0 }
537+
public var fieldIsLet: Bool { bridged.RefElementAddrInst_fieldIsLet() }
538538
}
539539

540540
final public class RefTailAddrInst : SingleValueInstruction, UnaryInstruction {
@@ -664,7 +664,7 @@ class ClassifyBridgeObjectInst : SingleValueInstruction, UnaryInstruction {}
664664

665665
final public class PartialApplyInst : SingleValueInstruction, ApplySite {
666666
public var numArguments: Int { bridged.PartialApplyInst_numArguments() }
667-
public var isOnStack: Bool { bridged.PartialApplyInst_isOnStack() != 0 }
667+
public var isOnStack: Bool { bridged.PartialApplyInst_isOnStack() }
668668

669669
public func calleeArgIndex(callerArgIndex: Int) -> Int {
670670
bridged.PartialApply_getCalleeArgIndexOfFirstAppliedArg() + callerArgIndex
@@ -719,13 +719,14 @@ class MarkMustCheckInst : SingleValueInstruction, UnaryInstruction {}
719719
public protocol Allocation : SingleValueInstruction { }
720720

721721
final public class AllocStackInst : SingleValueInstruction, Allocation {
722+
public var hasDynamicLifetime: Bool { bridged.AllocStackInst_hasDynamicLifetime() }
722723
}
723724

724725
public class AllocRefInstBase : SingleValueInstruction, Allocation {
725-
final public var isObjC: Bool { bridged.AllocRefInstBase_isObjc() != 0 }
726+
final public var isObjC: Bool { bridged.AllocRefInstBase_isObjc() }
726727

727728
final public var canAllocOnStack: Bool {
728-
bridged.AllocRefInstBase_canAllocOnStack() != 0
729+
bridged.AllocRefInstBase_canAllocOnStack()
729730
}
730731
}
731732

include/swift/SIL/SILBridging.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ struct BridgedFunction {
246246
}
247247

248248
bool hasSemanticsAttr(llvm::StringRef attrName) const {
249-
return getFunction()->hasSemanticsAttr(attrName) ? 1 : 0;
249+
return getFunction()->hasSemanticsAttr(attrName);
250250
}
251251

252252
swift::EffectsKind getEffectAttribute() const {
@@ -538,7 +538,7 @@ struct BridgedInstruction {
538538
return getAs<swift::RefElementAddrInst>()->getFieldIndex();
539539
}
540540

541-
SwiftInt RefElementAddrInst_fieldIsLet() const {
541+
bool RefElementAddrInst_fieldIsLet() const {
542542
return getAs<swift::RefElementAddrInst>()->getField()->isLet();
543543
}
544544

@@ -569,15 +569,19 @@ struct BridgedInstruction {
569569
return swift::ApplySite(getInst()).getCalleeArgIndexOfFirstAppliedArg();
570570
}
571571

572-
SwiftInt PartialApplyInst_isOnStack() const {
573-
return getAs<swift::PartialApplyInst>()->isOnStack() ? 1 : 0;
572+
bool PartialApplyInst_isOnStack() const {
573+
return getAs<swift::PartialApplyInst>()->isOnStack();
574574
}
575575

576-
SwiftInt AllocRefInstBase_isObjc() const {
576+
bool AllocStackInst_hasDynamicLifetime() const {
577+
return getAs<swift::AllocStackInst>()->hasDynamicLifetime();
578+
}
579+
580+
bool AllocRefInstBase_isObjc() const {
577581
return getAs<swift::AllocRefInstBase>()->isObjC();
578582
}
579583

580-
SwiftInt AllocRefInstBase_canAllocOnStack() const {
584+
bool AllocRefInstBase_canAllocOnStack() const {
581585
return getAs<swift::AllocRefInstBase>()->canAllocOnStack();
582586
}
583587

@@ -613,12 +617,12 @@ struct BridgedInstruction {
613617
return getAs<swift::BeginAccessInst>()->getEnforcement() == swift::SILAccessEnforcement::Static;
614618
}
615619

616-
SwiftInt CopyAddrInst_isTakeOfSrc() const {
617-
return getAs<swift::CopyAddrInst>()->isTakeOfSrc() ? 1 : 0;
620+
bool CopyAddrInst_isTakeOfSrc() const {
621+
return getAs<swift::CopyAddrInst>()->isTakeOfSrc();
618622
}
619623

620-
SwiftInt CopyAddrInst_isInitializationOfDest() const {
621-
return getAs<swift::CopyAddrInst>()->isInitializationOfDest() ? 1 : 0;
624+
bool CopyAddrInst_isInitializationOfDest() const {
625+
return getAs<swift::CopyAddrInst>()->isInitializationOfDest();
622626
}
623627

624628
void RefCountingInst_setIsAtomic(bool isAtomic) const {

0 commit comments

Comments
 (0)