Skip to content

Commit 8f3c7eb

Browse files
authored
Merge pull request swiftlang#5955 from hughbe/silgen-msvc
Fix errors and warnings building swift/SILGen on Windows using MSVC
2 parents 0a0c77e + 63d6b15 commit 8f3c7eb

18 files changed

+41
-11
lines changed

include/swift/SIL/SILArgumentConvention.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum class InoutAliasingAssumption {
3434
/// By design, this is exactly the same as ParameterConvention, plus
3535
/// Indirect_Out.
3636
struct SILArgumentConvention {
37-
enum : uint8_t {
37+
enum ConventionType : uint8_t {
3838
Indirect_In,
3939
Indirect_In_Guaranteed,
4040
Indirect_Inout,
@@ -79,7 +79,7 @@ struct SILArgumentConvention {
7979
llvm_unreachable("covered switch isn't covered?!");
8080
}
8181

82-
operator decltype(Value)() const { return Value; }
82+
operator ConventionType() const { return Value; }
8383

8484
bool isIndirectConvention() const {
8585
return Value <= SILArgumentConvention::Indirect_Out;

include/swift/SILOptimizer/PassManager/PassPipeline.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class SILPassPipelinePlan final {
4848
SILPassPipelinePlan() = default;
4949
~SILPassPipelinePlan() = default;
5050
SILPassPipelinePlan(const SILPassPipelinePlan &) = default;
51-
SILPassPipelinePlan(SILPassPipelinePlan &&) = delete;
5251

5352
// Each pass gets its own add-function.
5453
#define PASS(ID, NAME, DESCRIPTION) \

lib/SILGen/ArgumentSource.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ bool ArgumentSource::requiresCalleeToEvaluate() {
5757
case Kind::Expr:
5858
return isa<TupleShuffleExpr>(asKnownExpr());
5959
}
60+
61+
llvm_unreachable("Unhandled Kind in switch.");
6062
}
6163

6264
RValue ArgumentSource::getAsRValue(SILGenFunction &gen, SGFContext C) && {

lib/SILGen/RValue.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class ImplodeLoadableTupleValue
140140
case ImplodeKind::Copy:
141141
return v.copyUnmanaged(gen, l).forward(gen);
142142
}
143+
144+
llvm_unreachable("Unhandled ImplodeKind in switch.");
143145
}
144146

145147
ImplodeLoadableTupleValue(ArrayRef<ManagedValue> values,

lib/SILGen/SILGenApply.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ class Callee {
427427
case Kind::DynamicMethod:
428428
return Constant.uncurryLevel;
429429
}
430+
431+
llvm_unreachable("Unhandled Kind in switch.");
430432
}
431433

432434
EnumElementDecl *getEnumElementDecl() {
@@ -1487,7 +1489,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
14871489

14881490
Callee getCallee() {
14891491
assert(ApplyCallee && "did not find callee?!");
1490-
return *std::move(ApplyCallee);
1492+
return std::move(*ApplyCallee);
14911493
}
14921494

14931495
/// Ignore parentheses and implicit conversions.
@@ -3633,7 +3635,10 @@ void ArgEmitter::emitShuffle(Expr *inner,
36333635
// fill out varargsAddrs if necessary.
36343636
for (auto &extent : innerExtents) {
36353637
assert(extent.Used && "didn't use all the inner tuple elements!");
3636-
innerParams.append(extent.Params.begin(), extent.Params.end());
3638+
3639+
for (auto param : extent.Params) {
3640+
innerParams.push_back(param);
3641+
}
36373642

36383643
// Fill in the special destinations array.
36393644
if (innerSpecialDests) {

lib/SILGen/SILGenConvert.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ ManagedValue SILGenFunction::emitExistentialErasure(
667667
return manageBufferForExprResult(existential, existentialTL, C);
668668
}
669669
}
670+
671+
llvm_unreachable("Unhandled ExistentialRepresentation in switch.");
670672
}
671673

672674
ManagedValue SILGenFunction::emitClassMetatypeToObject(SILLocation loc,

lib/SILGen/SILGenExpr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,8 @@ visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) {
20912091
return RValue(SGF, E, ManagedValue::forUnmanaged(UnsafeRawPtrStruct));
20922092
}
20932093
}
2094+
2095+
llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch.");
20942096
}
20952097

20962098
RValue RValueEmitter::visitCollectionExpr(CollectionExpr *E, SGFContext C) {

lib/SILGen/SILGenFunction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ DeclName SILGenModule::getMagicFunctionName(SILDeclRef ref) {
128128
return getMagicFunctionName(cast<EnumElementDecl>(ref.getDecl())
129129
->getDeclContext());
130130
}
131+
132+
llvm_unreachable("Unhandled SILDeclRefKind in switch.");
131133
}
132134

133135
SILValue SILGenFunction::emitGlobalFunctionRef(SILLocation loc,

lib/SILGen/SILGenPattern.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ static bool isWildcardPattern(const Pattern *p) {
222222
case PatternKind::Var:
223223
return isWildcardPattern(p->getSemanticsProvidingPattern());
224224
}
225+
226+
llvm_unreachable("Unhandled PatternKind in switch.");
225227
}
226228

227229
/// Check to see if the given pattern is a specializing pattern,
@@ -284,6 +286,8 @@ static Pattern *getSimilarSpecializingPattern(Pattern *p, Pattern *first) {
284286
case PatternKind::Typed:
285287
llvm_unreachable("not semantic");
286288
}
289+
290+
llvm_unreachable("Unhandled PatternKind in switch.");
287291
}
288292

289293
namespace {

lib/SILGen/SILGenPoly.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,8 @@ getWitnessFunctionType(SILGenModule &SGM,
27882788
case WitnessDispatchKind::Class:
27892789
return SGM.Types.getConstantOverrideType(witness);
27902790
}
2791+
2792+
llvm_unreachable("Unhandled WitnessDispatchKind in switch.");
27912793
}
27922794

27932795
static SILValue
@@ -2808,6 +2810,8 @@ getWitnessFunctionRef(SILGenFunction &gen,
28082810
SILValue selfPtr = witnessParams.back().getValue();
28092811
return gen.B.createClassMethod(loc, selfPtr, witness);
28102812
}
2813+
2814+
llvm_unreachable("Unhandled WitnessDispatchKind in switch.");
28112815
}
28122816

28132817
static CanType dropLastElement(CanType type) {

lib/SILGen/SILGenProfiling.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class CounterExpr {
226226
case Kind::Ref:
227227
return LHS->expand(Builder, Counters);
228228
}
229+
230+
llvm_unreachable("Unhandled Kind in switch.");
229231
}
230232
};
231233

@@ -694,6 +696,8 @@ getEquivalentPGOLinkage(FormalLinkage Linkage) {
694696
case FormalLinkage::Private:
695697
return llvm::GlobalValue::PrivateLinkage;
696698
}
699+
700+
llvm_unreachable("Unhandled FormalLinkage in switch.");
697701
}
698702

699703
void SILGenProfiling::assignRegionCounters(Decl *Root) {

lib/SILOptimizer/IPO/CapturePromotion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static std::string getSpecializedName(SILFunction *F,
387387
IsFragile_t Fragile,
388388
IndicesSet &PromotableIndices) {
389389
Mangle::Mangler M;
390-
auto P = SpecializationPass::CapturePromotion;
390+
auto P = Demangle::SpecializationPass::CapturePromotion;
391391
FunctionSignatureSpecializationMangler OldFSSM(P, M, Fragile, F);
392392
NewMangling::FunctionSignatureSpecializationMangler NewFSSM(P, Fragile, F);
393393
CanSILFunctionType FTy = F->getLoweredFunctionType();

lib/SILOptimizer/IPO/CapturePropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static std::string getClonedName(PartialApplyInst *PAI, IsFragile_t Fragile,
7272
SILFunction *F) {
7373

7474
Mangle::Mangler M;
75-
auto P = SpecializationPass::CapturePropagation;
75+
auto P = Demangle::SpecializationPass::CapturePropagation;
7676
FunctionSignatureSpecializationMangler OldMangler(P, M, Fragile, F);
7777
NewMangling::FunctionSignatureSpecializationMangler NewMangler(P, Fragile, F);
7878

lib/SILOptimizer/IPO/ClosureSpecializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ IsFragile_t CallSiteDescriptor::isFragile() const {
398398

399399
std::string CallSiteDescriptor::createName() const {
400400
Mangle::Mangler M;
401-
auto P = SpecializationPass::ClosureSpecializer;
401+
auto P = Demangle::SpecializationPass::ClosureSpecializer;
402402
FunctionSignatureSpecializationMangler OldFSSM(P, M, isFragile(),
403403
getApplyCallee());
404404
NewMangling::FunctionSignatureSpecializationMangler NewFSSM(P, isFragile(),

lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ StringRef swift::PassKindName(PassKind Kind) {
146146
case PassKind::invalidPassKind:
147147
llvm_unreachable("Invalid pass kind?!");
148148
}
149+
150+
llvm_unreachable("Unhandled PassKind in switch.");
149151
}
150152

151153
StringRef swift::PassKindID(PassKind Kind) {
@@ -157,4 +159,6 @@ StringRef swift::PassKindID(PassKind Kind) {
157159
case PassKind::invalidPassKind:
158160
llvm_unreachable("Invalid pass kind?!");
159161
}
162+
163+
llvm_unreachable("Unhandled PassKind in switch.");
160164
}

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static std::string getClonedName(SILFunction *F,
521521
IsFragile_t Fragile,
522522
ParamIndexList &PromotedParamIndices) {
523523
Mangle::Mangler M;
524-
auto P = SpecializationPass::AllocBoxToStack;
524+
auto P = Demangle::SpecializationPass::AllocBoxToStack;
525525
FunctionSignatureSpecializationMangler OldFSSM(P, M, Fragile, F);
526526
NewMangling::FunctionSignatureSpecializationMangler NewFSSM(P, Fragile, F);
527527
for (unsigned i : PromotedParamIndices) {

lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ class FunctionSignatureOpts : public SILFunctionTransform {
923923
// going to change, make sure the mangler is aware of all the changes done
924924
// to the function.
925925
Mangle::Mangler M;
926-
auto P = SpecializationPass::FunctionSignatureOpts;
926+
auto P = Demangle::SpecializationPass::FunctionSignatureOpts;
927927
FunctionSignatureSpecializationMangler OldFM(P, M, F->isFragile(), F);
928928
NewMangling::FunctionSignatureSpecializationMangler NewFM(P, F->isFragile(),
929929
F);

lib/SILOptimizer/Utils/SpecializationMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ std::string PartialSpecializationMangler::mangle() {
9595
//===----------------------------------------------------------------------===//
9696

9797
FunctionSignatureSpecializationMangler::
98-
FunctionSignatureSpecializationMangler(SpecializationPass P,
98+
FunctionSignatureSpecializationMangler(Demangle::SpecializationPass P,
9999
IsFragile_t Fragile, SILFunction *F)
100100
: SpecializationMangler(P, Fragile, F) {
101101
for (unsigned i = 0, e = F->getLoweredFunctionType()->getNumSILArguments();

0 commit comments

Comments
 (0)