Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/swift/Serialization/ModuleFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ModuleFile : public LazyMemberLoader {
template <typename T>
class Serialized {
private:
using RawBitOffset = decltype(DeclTypeCursor.GetCurrentBitNo());
using RawBitOffset = uint64_t;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strange bug - only occurs with nested generic classes - https://connect.microsoft.com/VisualStudio/feedback/details/3116520


using ImplTy = PointerUnion<T, serialization::BitOffset>;
ImplTy Value;
Expand Down Expand Up @@ -310,7 +310,7 @@ class ModuleFile : public LazyMemberLoader {
std::unique_ptr<GroupNameTable> GroupNamesMap;
std::unique_ptr<SerializedDeclCommentTable> DeclCommentTable;

struct {
struct ModuleBits {
/// The decl ID of the main class in this module file, if it has one.
unsigned EntryPointDeclID : 31;

Expand All @@ -336,7 +336,7 @@ class ModuleFile : public LazyMemberLoader {
// Explicitly pad out to the next word boundary.
unsigned : 0;
} Bits = {};
static_assert(sizeof(Bits) <= 8, "The bit set should be small");
static_assert(sizeof(ModuleBits) <= 8, "The bit set should be small");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


void setStatus(Status status) {
Bits.Status = static_cast<unsigned>(status);
Expand Down
4 changes: 4 additions & 0 deletions lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace {
#define RECORD(Id) case decls_block::Id: return #Id;
#include "swift/Serialization/DeclTypeRecordNodes.def"
}

llvm_unreachable("Unhandled RecordKind in switch.");
}

virtual void print(raw_ostream &os) const override {
Expand Down Expand Up @@ -4319,4 +4321,6 @@ Optional<ForeignErrorConvention> ModuleFile::maybeReadForeignErrorConvention() {
owned, replaced,
canErrorParameterType);
}

llvm_unreachable("Unhandled ForeignErrorConvention in switch.");
}
22 changes: 22 additions & 0 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ static const Decl *getDeclForContext(const DeclContext *DC) {
case DeclContextKind::SubscriptDecl:
return cast<SubscriptDecl>(DC);
}

llvm_unreachable("Unhandled DeclContextKind in switch.");
}

namespace {
Expand Down Expand Up @@ -783,6 +785,8 @@ static uint8_t getRawStableDefaultArgumentKind(swift::DefaultArgumentKind kind)
CASE(EmptyDictionary)
#undef CASE
}

llvm_unreachable("Unhandled DefaultArgumentKind in switch.");
}

static uint8_t getRawStableMetatypeRepresentation(AnyMetatypeType *metatype) {
Expand Down Expand Up @@ -934,6 +938,8 @@ static uint8_t getRawStableRequirementKind(RequirementKind kind) {
CASE(SameType)
}
#undef CASE

llvm_unreachable("Unhandled RequirementKind in switch.");
}

void Serializer::writeGenericRequirements(ArrayRef<Requirement> requirements,
Expand Down Expand Up @@ -1283,6 +1289,8 @@ static uint8_t getRawStableOptionalTypeKind(swift::OptionalTypeKind kind) {
return static_cast<uint8_t>(
serialization::OptionalTypeKind::ImplicitlyUnwrappedOptional);
}

llvm_unreachable("Unhandled OptionalTypeKind in switch.");
}

static bool shouldSerializeMember(Decl *D) {
Expand Down Expand Up @@ -1320,6 +1328,8 @@ static bool shouldSerializeMember(Decl *D) {
case DeclKind::Func:
return true;
}

llvm_unreachable("Unhandled DeclKind in switch.");
}

void Serializer::writeMembers(DeclRange members, bool isClass) {
Expand Down Expand Up @@ -1386,6 +1396,8 @@ static serialization::AccessorKind getStableAccessorKind(swift::AccessorKind K){
CASE(MutableAddressor)
#undef CASE
}

llvm_unreachable("Unhandled AccessorKind in switch.");
}

static serialization::CtorInitializerKind
Expand All @@ -1399,6 +1411,8 @@ getStableCtorInitializerKind(swift::CtorInitializerKind K){
CASE(ConvenienceFactory)
#undef CASE
}

llvm_unreachable("Unhandled CtorInitializerKind in switch.");
}

void Serializer::writeCrossReference(const DeclContext *DC, uint32_t pathLen) {
Expand Down Expand Up @@ -1613,6 +1627,8 @@ static uint8_t getRawStableAssociativity(swift::Associativity assoc) {
case swift::Associativity::None:
return serialization::Associativity::NonAssociative;
}

llvm_unreachable("Unhandled Associativity in switch.");
}

static serialization::StaticSpellingKind
Expand All @@ -1625,6 +1641,8 @@ getStableStaticSpelling(swift::StaticSpellingKind SS) {
case swift::StaticSpellingKind::KeywordClass:
return serialization::StaticSpellingKind::KeywordClass;
}

llvm_unreachable("Unhandled StaticSpellingKind in switch.");
}

static uint8_t getRawStableAccessibility(Accessibility access) {
Expand All @@ -1639,6 +1657,8 @@ static uint8_t getRawStableAccessibility(Accessibility access) {
CASE(Open)
#undef CASE
}

llvm_unreachable("Unhandled AccessibilityKind in switch.");
}

#ifndef NDEBUG
Expand Down Expand Up @@ -2029,6 +2049,8 @@ static ForeignErrorConventionKind getRawStableForeignErrorConventionKind(
case ForeignErrorConvention::NonNilError:
return ForeignErrorConventionKind::NonNilError;
}

llvm_unreachable("Unhandled ForeignErrorConvention in switch.");
}

void Serializer::writeForeignErrorConvention(const ForeignErrorConvention &fec){
Expand Down