Skip to content

Commit bf37455

Browse files
authored
Merge pull request swiftlang#28954 from compnerd/brace-yourself
SIL: use `std::array` for `SILSuccessor` array
2 parents f2a2a82 + 2b17d36 commit bf37455

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "llvm/ADT/ilist.h"
4343
#include "llvm/ADT/ilist_node.h"
4444
#include "llvm/Support/TrailingObjects.h"
45+
#include <array>
4546

4647
namespace swift {
4748

@@ -7138,12 +7139,12 @@ class YieldInst final
71387139
YieldInst, TermInst> {
71397140
friend SILBuilder;
71407141

7141-
SILSuccessor DestBBs[2];
7142+
std::array<SILSuccessor, 2> DestBBs;
71427143

71437144
YieldInst(SILDebugLocation loc, ArrayRef<SILValue> yieldedValues,
71447145
SILBasicBlock *normalBB, SILBasicBlock *unwindBB)
71457146
: InstructionBaseWithTrailingOperands(yieldedValues, loc),
7146-
DestBBs{{this, normalBB}, {this, unwindBB}} {}
7147+
DestBBs{{{this, normalBB}, {this, unwindBB}}} {}
71477148

71487149
static YieldInst *create(SILDebugLocation loc,
71497150
ArrayRef<SILValue> yieldedValues,
@@ -7253,7 +7254,8 @@ class CondBranchInst final
72537254
FalseIdx
72547255
};
72557256
private:
7256-
SILSuccessor DestBBs[2];
7257+
std::array<SILSuccessor, 2> DestBBs;
7258+
72577259
/// The number of arguments for the True branch.
72587260
unsigned getNumTrueArgs() const {
72597261
return SILInstruction::Bits.CondBranchInst.NumTrueArgs;
@@ -7638,7 +7640,7 @@ class DynamicMethodBranchInst
76387640

76397641
SILDeclRef Member;
76407642

7641-
SILSuccessor DestBBs[2];
7643+
std::array<SILSuccessor, 2> DestBBs;
76427644

76437645
/// The operand.
76447646
FixedOperandList<1> Operands;
@@ -7686,7 +7688,7 @@ class CheckedCastBranchInst final:
76867688
CanType DestFormalTy;
76877689
bool IsExact;
76887690

7689-
SILSuccessor DestBBs[2];
7691+
std::array<SILSuccessor, 2> DestBBs;
76907692

76917693
CheckedCastBranchInst(SILDebugLocation DebugLoc, bool IsExact,
76927694
SILValue Operand,
@@ -7698,8 +7700,8 @@ class CheckedCastBranchInst final:
76987700
TypeDependentOperands),
76997701
DestLoweredTy(DestLoweredTy),
77007702
DestFormalTy(DestFormalTy),
7701-
IsExact(IsExact), DestBBs{{this, SuccessBB, Target1Count},
7702-
{this, FailureBB, Target2Count}} {}
7703+
IsExact(IsExact), DestBBs{{{this, SuccessBB, Target1Count},
7704+
{this, FailureBB, Target2Count}}} {}
77037705

77047706
static CheckedCastBranchInst *
77057707
create(SILDebugLocation DebugLoc, bool IsExact, SILValue Operand,
@@ -7746,7 +7748,7 @@ class CheckedCastValueBranchInst final
77467748
SILType DestLoweredTy;
77477749
CanType DestFormalTy;
77487750

7749-
SILSuccessor DestBBs[2];
7751+
std::array<SILSuccessor, 2> DestBBs;
77507752

77517753
CheckedCastValueBranchInst(SILDebugLocation DebugLoc,
77527754
SILValue Operand, CanType SourceFormalTy,
@@ -7757,7 +7759,7 @@ class CheckedCastValueBranchInst final
77577759
TypeDependentOperands),
77587760
SourceFormalTy(SourceFormalTy),
77597761
DestLoweredTy(DestLoweredTy), DestFormalTy(DestFormalTy),
7760-
DestBBs{{this, SuccessBB}, {this, FailureBB}} {}
7762+
DestBBs{{{this, SuccessBB}, {this, FailureBB}}} {}
77617763

77627764
static CheckedCastValueBranchInst *
77637765
create(SILDebugLocation DebugLoc,
@@ -7791,7 +7793,7 @@ class CheckedCastAddrBranchInst
77917793
CastConsumptionKind ConsumptionKind;
77927794

77937795
FixedOperandList<2> Operands;
7794-
SILSuccessor DestBBs[2];
7796+
std::array<SILSuccessor, 2> DestBBs;
77957797

77967798
CanType SourceType;
77977799
CanType TargetType;
@@ -7803,8 +7805,8 @@ class CheckedCastAddrBranchInst
78037805
ProfileCounter Target1Count,
78047806
ProfileCounter Target2Count)
78057807
: InstructionBase(DebugLoc), ConsumptionKind(consumptionKind),
7806-
Operands{this, src, dest}, DestBBs{{this, successBB, Target1Count},
7807-
{this, failureBB, Target2Count}},
7808+
Operands{this, src, dest}, DestBBs{{{this, successBB, Target1Count},
7809+
{this, failureBB, Target2Count}}},
78087810
SourceType(srcType), TargetType(targetType) {
78097811
assert(ConsumptionKind != CastConsumptionKind::BorrowAlways &&
78107812
"BorrowAlways is not supported on addresses");
@@ -7856,7 +7858,7 @@ class TryApplyInstBase : public TermInst {
78567858
ErrorIdx
78577859
};
78587860
private:
7859-
SILSuccessor DestBBs[2];
7861+
std::array<SILSuccessor, 2> DestBBs;
78607862

78617863
protected:
78627864
TryApplyInstBase(SILInstructionKind valueKind, SILDebugLocation Loc,

lib/SIL/SILInstructions.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ TryApplyInstBase::TryApplyInstBase(SILInstructionKind kind,
573573
SILDebugLocation loc,
574574
SILBasicBlock *normalBB,
575575
SILBasicBlock *errorBB)
576-
: TermInst(kind, loc), DestBBs{{this, normalBB}, {this, errorBB}} {}
576+
: TermInst(kind, loc), DestBBs{{{this, normalBB}, {this, errorBB}}} {}
577577

578578
TryApplyInst::TryApplyInst(
579579
SILDebugLocation Loc, SILValue callee, SILType substCalleeTy,
@@ -1267,8 +1267,7 @@ CondBranchInst::CondBranchInst(SILDebugLocation Loc, SILValue Condition,
12671267
unsigned NumFalse, ProfileCounter TrueBBCount,
12681268
ProfileCounter FalseBBCount)
12691269
: InstructionBaseWithTrailingOperands(Condition, Args, Loc),
1270-
DestBBs{{this, TrueBB, TrueBBCount},
1271-
{this, FalseBB, FalseBBCount}} {
1270+
DestBBs{{{this, TrueBB, TrueBBCount}, {this, FalseBB, FalseBBCount}}} {
12721271
assert(Args.size() == (NumTrue + NumFalse) && "Invalid number of args");
12731272
SILInstruction::Bits.CondBranchInst.NumTrueArgs = NumTrue;
12741273
assert(SILInstruction::Bits.CondBranchInst.NumTrueArgs == NumTrue &&
@@ -1706,7 +1705,7 @@ DynamicMethodBranchInst::DynamicMethodBranchInst(SILDebugLocation Loc,
17061705
SILBasicBlock *NoMethodBB)
17071706
: InstructionBase(Loc),
17081707
Member(Member),
1709-
DestBBs{{this, HasMethodBB}, {this, NoMethodBB}},
1708+
DestBBs{{{this, HasMethodBB}, {this, NoMethodBB}}},
17101709
Operands(this, Operand)
17111710
{
17121711
}

0 commit comments

Comments
 (0)