Skip to content

Commit 1aa951d

Browse files
hughbejrose-apple
authored andcommitted
Fix errors and warnings building swift/IRGen on Windows using MSVC (#5958)
1 parent 1f6a8ff commit 1aa951d

File tree

13 files changed

+52
-5
lines changed

13 files changed

+52
-5
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ llvm::Type *SignatureExpansion::expandDirectResult() {
317317
return schema.getScalarResultType(IGM);
318318
}
319319
}
320+
321+
llvm_unreachable("Not a valid SILFunctionLanguage.");
320322
}
321323

322324
static const clang::FieldDecl *

lib/IRGen/GenClangType.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ getClangBuiltinTypeFromKind(const clang::ASTContext &context,
8282
return context.SingletonId;
8383
#include "clang/Basic/OpenCLImageTypes.def"
8484
}
85+
86+
llvm_unreachable("Not a valid BuiltinType.");
8587
}
8688

8789
static clang::CanQualType getClangSelectorType(
@@ -490,6 +492,8 @@ GenClangType::visitBoundGenericType(CanBoundGenericType type) {
490492
return getCanonicalType(fnPtrTy);
491493
}
492494
}
495+
496+
llvm_unreachable("Not a valid StructKind.");
493497
}
494498

495499
clang::CanQualType GenClangType::visitEnumType(CanEnumType type) {

lib/IRGen/GenEnum.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,9 @@ namespace {
950950
unsigned getFixedExtraInhabitantCount(IRGenModule &IGM) const override {
951951
unsigned bits = cast<FixedTypeInfo>(TI)->getFixedSize().getValueInBits();
952952
assert(bits < 32 && "freakishly huge no-payload enum");
953-
return (1U << bits) - ElementsWithNoPayload.size();
953+
954+
size_t shifted = static_cast<size_t>(static_cast<size_t>(1) << bits);
955+
return shifted - ElementsWithNoPayload.size();
954956
}
955957

956958
APInt getFixedExtraInhabitantValue(IRGenModule &IGM,
@@ -2088,6 +2090,8 @@ namespace {
20882090
case Normal:
20892091
llvm_unreachable("not a refcounted payload");
20902092
}
2093+
2094+
llvm_unreachable("Not a valid CopyDestroyStrategy");
20912095
}
20922096

20932097
void retainRefcountedPayload(IRGenFunction &IGF,
@@ -2960,6 +2964,8 @@ namespace {
29602964
case Normal:
29612965
llvm_unreachable("not a refcounted payload");
29622966
}
2967+
2968+
llvm_unreachable("Not a valid CopyDestroyStrategy.");
29632969
}
29642970

29652971
void retainRefcountedPayload(IRGenFunction &IGF,
@@ -5669,7 +5675,7 @@ const TypeInfo *TypeConverter::convertEnumType(TypeBase *key, CanType type,
56695675
}
56705676
auto tagBits = strategy->getTagBitsForPayloads();
56715677
assert(tagBits.count() >= 32
5672-
|| (1U << tagBits.count())
5678+
|| static_cast<size_t>(static_cast<size_t>(1) << tagBits.count())
56735679
>= strategy->getElementsWithPayload().size());
56745680
DEBUG(llvm::dbgs() << " payload tag bits:\t";
56755681
displayBitMask(tagBits));

lib/IRGen/GenHeap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,8 @@ llvm::Type *IRGenModule::getReferenceType(ReferenceCounting refcounting) {
10411041
case ReferenceCounting::Error:
10421042
return ErrorPtrTy;
10431043
}
1044+
1045+
llvm_unreachable("Not a valid ReferenceCounting.");
10441046
}
10451047

10461048
#define DEFINE_BINARY_OPERATION(KIND, RESULT, TYPE1, TYPE2) \

lib/IRGen/GenMeta.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,8 @@ namespace {
16731673
// All block types look like Builtin.UnknownObject.
16741674
return emitDirectMetadataRef(C.TheUnknownObjectType);
16751675
}
1676+
1677+
llvm_unreachable("Not a valid SILFunctionType.");
16761678
}
16771679

16781680
llvm::Value *visitAnyMetatypeType(CanAnyMetatypeType type) {
@@ -1698,6 +1700,8 @@ namespace {
16981700
// FIXME: It'd be nice not to need a runtime call here.
16991701
return IGF.emitTypeMetadataRef(type);
17001702
}
1703+
1704+
llvm_unreachable("Not a valid MetatypeRepresentation.");
17011705
}
17021706

17031707
/// Try to find the metatype in local data.
@@ -1852,6 +1856,8 @@ namespace {
18521856
// All block types look like Builtin.UnknownObject.
18531857
return emitFromValueWitnessTable(C.TheUnknownObjectType);
18541858
}
1859+
1860+
llvm_unreachable("Not a valid SILFunctionType.");
18551861
}
18561862

18571863
llvm::Value *visitAnyMetatypeType(CanAnyMetatypeType type) {
@@ -1870,6 +1876,8 @@ namespace {
18701876
return emitFromValueWitnessTable(
18711877
CanMetatypeType::get(IGF.IGM.Context.TheNativeObjectType));
18721878
}
1879+
1880+
llvm_unreachable("Not a valid MetatypeRepresentation.");
18731881
}
18741882

18751883
llvm::Value *visitAnyClassType(ClassDecl *classDecl) {
@@ -1887,6 +1895,8 @@ namespace {
18871895
case ReferenceCounting::Error:
18881896
llvm_unreachable("classes shouldn't have this kind of refcounting");
18891897
}
1898+
1899+
llvm_unreachable("Not a valid ReferenceCounting.");
18901900
}
18911901

18921902
llvm::Value *visitClassType(CanClassType type) {
@@ -4475,6 +4485,8 @@ static llvm::Value *emitLoadOfHeapMetadataRef(IRGenFunction &IGF,
44754485
return objcClass;
44764486
}
44774487
}
4488+
4489+
llvm_unreachable("Not a valid IsaEncoding.");
44784490
}
44794491

44804492
/// Given an object of class type, produce the heap metadata reference
@@ -5559,6 +5571,8 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
55595571
case KnownProtocolKind::ErrorCodeProtocol:
55605572
return SpecialProtocol::None;
55615573
}
5574+
5575+
llvm_unreachable("Not a valid KnownProtocolKind.");
55625576
}
55635577

55645578
namespace {

lib/IRGen/GenProto.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,8 @@ bool irgen::hasPolymorphicParameters(CanSILFunctionType ty) {
18151815
// Always carries polymorphic parameters for the Self type.
18161816
return true;
18171817
}
1818+
1819+
llvm_unreachable("Not a valid SILFunctionTypeRepresentation.");
18181820
}
18191821

18201822
static

lib/IRGen/GenType.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,10 @@ FixedTypeInfo::getSpareBitExtraInhabitantIndex(IRGenFunction &IGF,
311311
llvm::Value *spareIdx
312312
= emitGatherSpareBits(IGF, SpareBits, val, numOccupiedBits, 31);
313313
// Unbias by subtracting one.
314+
315+
uint64_t shifted = static_cast<uint64_t>(1 << numOccupiedBits);
314316
spareIdx = IGF.Builder.CreateSub(spareIdx,
315-
llvm::ConstantInt::get(spareIdx->getType(), 1 << numOccupiedBits));
317+
llvm::ConstantInt::get(spareIdx->getType(), shifted));
316318
idx = IGF.Builder.CreateOr(idx, spareIdx);
317319
}
318320
idx = IGF.Builder.CreateZExt(idx, IGF.IGM.Int32Ty);
@@ -743,6 +745,8 @@ IRGenModule::getReferenceObjectTypeInfo(ReferenceCounting refcounting) {
743745
case ReferenceCounting::ObjC:
744746
llvm_unreachable("not implemented");
745747
}
748+
749+
llvm_unreachable("Not a valid ReferenceCounting.");
746750
}
747751

748752
const LoadableTypeInfo &IRGenModule::getNativeObjectTypeInfo() {
@@ -1815,6 +1819,8 @@ llvm::Value *IRGenFunction::getLocalSelfMetadata() {
18151819
case ObjectReference:
18161820
return emitDynamicTypeOfOpaqueHeapObject(*this, LocalSelf);
18171821
}
1822+
1823+
llvm_unreachable("Not a valid LocalSelfKind.");
18181824
}
18191825

18201826
void IRGenFunction::setLocalSelfMetadata(llvm::Value *value,

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
378378

379379
// Only use the new calling conventions on platforms that support it.
380380
auto Arch = Triple.getArch();
381+
(void)Arch;
381382
if (SWIFT_RT_USE_RegisterPreservingCC &&
382383
Arch == llvm::Triple::ArchType::aarch64)
383384
RegisterPreservingCC = SWIFT_LLVM_CC(RegisterPreservingCC);

lib/IRGen/IRGenModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ class IRGenModule {
505505
case ReferenceCounting::Error:
506506
llvm_unreachable("unowned references to this type are not supported");
507507
}
508+
509+
llvm_unreachable("Not a valid ReferenceCounting.");
508510
}
509511

510512
/// Return the spare bit mask to use for types that comprise heap object

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,8 @@ static llvm::Value *getClassMetatype(IRGenFunction &IGF,
16531653
case MetatypeRepresentation::ObjC:
16541654
return emitHeapMetadataRefForHeapObject(IGF, baseValue, instanceType);
16551655
}
1656+
1657+
llvm_unreachable("Not a valid MetatypeRepresentation.");
16561658
}
16571659

16581660
void IRGenSILFunction::visitValueMetatypeInst(swift::ValueMetatypeInst *i) {
@@ -2141,6 +2143,8 @@ getPartialApplicationFunction(IRGenSILFunction &IGF, SILValue v,
21412143
return std::make_tuple(fn, context, fnType);
21422144
}
21432145
}
2146+
2147+
llvm_unreachable("Not a valid SILFunctionType.");
21442148
}
21452149

21462150
void IRGenSILFunction::visitPartialApplyInst(swift::PartialApplyInst *i) {

0 commit comments

Comments
 (0)