mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #28214 from francisvm/bitstream-changes/master
Cherry-pick LLVM Bitstream changes
This commit is contained in:
@@ -139,13 +139,13 @@ void ExtensionError::anchor() {}
|
||||
|
||||
/// Skips a single record in the bitstream.
|
||||
///
|
||||
/// Returns true if the next entry is a record of type \p recordKind.
|
||||
/// Destroys the stream position if the next entry is not a record.
|
||||
static void skipRecord(llvm::BitstreamCursor &cursor, unsigned recordKind) {
|
||||
auto next = cursor.advance(AF_DontPopBlockAtEnd);
|
||||
auto next = llvm::cantFail<llvm::BitstreamEntry>(
|
||||
cursor.advance(AF_DontPopBlockAtEnd));
|
||||
assert(next.Kind == llvm::BitstreamEntry::Record);
|
||||
|
||||
unsigned kind = cursor.skipRecord(next.ID);
|
||||
unsigned kind = llvm::cantFail<unsigned>(cursor.skipRecord(next.ID));
|
||||
assert(kind == recordKind);
|
||||
(void)kind;
|
||||
}
|
||||
@@ -227,8 +227,10 @@ ParameterList *ModuleFile::readParameterList() {
|
||||
using namespace decls_block;
|
||||
|
||||
SmallVector<uint64_t, 8> scratch;
|
||||
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
unsigned recordID =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(entry.ID, scratch));
|
||||
assert(recordID == PARAMETERLIST);
|
||||
(void) recordID;
|
||||
|
||||
@@ -260,7 +262,8 @@ Expected<Pattern *> ModuleFile::readPattern(DeclContext *owningDC) {
|
||||
SmallVector<uint64_t, 8> scratch;
|
||||
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
auto next = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry next =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (next.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
@@ -272,7 +275,8 @@ Expected<Pattern *> ModuleFile::readPattern(DeclContext *owningDC) {
|
||||
pattern->setType(type);
|
||||
};
|
||||
|
||||
unsigned kind = DeclTypeCursor.readRecord(next.ID, scratch);
|
||||
unsigned kind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(next.ID, scratch));
|
||||
switch (kind) {
|
||||
case decls_block::PAREN_PATTERN: {
|
||||
bool isImplicit;
|
||||
@@ -303,10 +307,10 @@ Expected<Pattern *> ModuleFile::readPattern(DeclContext *owningDC) {
|
||||
SmallVector<TuplePatternElt, 8> elements;
|
||||
for ( ; count > 0; --count) {
|
||||
scratch.clear();
|
||||
next = DeclTypeCursor.advance();
|
||||
next = fatalIfUnexpected(DeclTypeCursor.advance());
|
||||
assert(next.Kind == llvm::BitstreamEntry::Record);
|
||||
|
||||
kind = DeclTypeCursor.readRecord(next.ID, scratch);
|
||||
kind = fatalIfUnexpected(DeclTypeCursor.readRecord(next.ID, scratch));
|
||||
assert(kind == decls_block::TUPLE_PATTERN_ELT);
|
||||
|
||||
// FIXME: Add something for this record or remove it.
|
||||
@@ -398,10 +402,11 @@ SILLayout *ModuleFile::readSILLayout(llvm::BitstreamCursor &Cursor) {
|
||||
|
||||
SmallVector<uint64_t, 16> scratch;
|
||||
|
||||
auto next = Cursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry next =
|
||||
fatalIfUnexpected(Cursor.advance(AF_DontPopBlockAtEnd));
|
||||
assert(next.Kind == llvm::BitstreamEntry::Record);
|
||||
|
||||
unsigned kind = Cursor.readRecord(next.ID, scratch);
|
||||
unsigned kind = fatalIfUnexpected(Cursor.readRecord(next.ID, scratch));
|
||||
switch (kind) {
|
||||
case decls_block::SIL_LAYOUT: {
|
||||
GenericSignatureID rawGenericSig;
|
||||
@@ -445,13 +450,14 @@ ModuleFile::readConformanceChecked(llvm::BitstreamCursor &Cursor,
|
||||
|
||||
SmallVector<uint64_t, 16> scratch;
|
||||
|
||||
auto next = Cursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry next =
|
||||
fatalIfUnexpected(Cursor.advance(AF_DontPopBlockAtEnd));
|
||||
assert(next.Kind == llvm::BitstreamEntry::Record);
|
||||
|
||||
if (getContext().Stats)
|
||||
getContext().Stats->getFrontendCounters().NumConformancesDeserialized++;
|
||||
|
||||
unsigned kind = Cursor.readRecord(next.ID, scratch);
|
||||
unsigned kind = fatalIfUnexpected(Cursor.readRecord(next.ID, scratch));
|
||||
switch (kind) {
|
||||
case INVALID_PROTOCOL_CONFORMANCE: {
|
||||
return ProtocolConformanceRef::forInvalid();
|
||||
@@ -592,8 +598,8 @@ NormalProtocolConformance *ModuleFile::readNormalConformance(
|
||||
|
||||
// Find the conformance record.
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(conformanceEntry);
|
||||
auto entry = DeclTypeCursor.advance();
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(conformanceEntry));
|
||||
llvm::BitstreamEntry entry = fatalIfUnexpected(DeclTypeCursor.advance());
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
@@ -603,9 +609,11 @@ NormalProtocolConformance *ModuleFile::readNormalConformance(
|
||||
ArrayRef<uint64_t> rawIDs;
|
||||
SmallVector<uint64_t, 16> scratch;
|
||||
|
||||
unsigned kind = DeclTypeCursor.readRecord(entry.ID, scratch);
|
||||
unsigned kind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(entry.ID, scratch));
|
||||
if (kind != NORMAL_PROTOCOL_CONFORMANCE)
|
||||
fatal();
|
||||
|
||||
NormalProtocolConformanceLayout::readRecord(scratch, protoID,
|
||||
contextID, typeCount,
|
||||
valueCount, conformanceCount,
|
||||
@@ -652,11 +660,13 @@ GenericParamList *ModuleFile::maybeReadGenericParams(DeclContext *DC) {
|
||||
SmallVector<uint64_t, 8> scratch;
|
||||
StringRef blobData;
|
||||
|
||||
auto next = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry next =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (next.Kind != llvm::BitstreamEntry::Record)
|
||||
return nullptr;
|
||||
|
||||
unsigned kind = DeclTypeCursor.readRecord(next.ID, scratch, &blobData);
|
||||
unsigned kind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(next.ID, scratch, &blobData));
|
||||
if (kind != GENERIC_PARAM_LIST)
|
||||
return nullptr;
|
||||
lastRecordOffset.reset();
|
||||
@@ -701,12 +711,14 @@ llvm::Error ModuleFile::readGenericRequirementsChecked(
|
||||
lastRecordOffset.reset();
|
||||
bool shouldContinue = true;
|
||||
|
||||
auto entry = Cursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(Cursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
break;
|
||||
|
||||
scratch.clear();
|
||||
unsigned recordID = Cursor.readRecord(entry.ID, scratch, &blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
Cursor.readRecord(entry.ID, scratch, &blobData));
|
||||
switch (recordID) {
|
||||
case GENERIC_REQUIREMENT: {
|
||||
uint8_t rawKind;
|
||||
@@ -830,29 +842,36 @@ llvm::Error ModuleFile::readGenericRequirementsChecked(
|
||||
}
|
||||
|
||||
/// Advances past any records that might be part of a requirement signature.
|
||||
static void skipGenericRequirements(llvm::BitstreamCursor &Cursor) {
|
||||
static llvm::Error skipGenericRequirements(llvm::BitstreamCursor &Cursor) {
|
||||
using namespace decls_block;
|
||||
|
||||
BCOffsetRAII lastRecordOffset(Cursor);
|
||||
|
||||
while (true) {
|
||||
auto entry = Cursor.advance(AF_DontPopBlockAtEnd);
|
||||
Expected<llvm::BitstreamEntry> maybeEntry =
|
||||
Cursor.advance(AF_DontPopBlockAtEnd);
|
||||
if (!maybeEntry)
|
||||
return maybeEntry.takeError();
|
||||
llvm::BitstreamEntry entry = maybeEntry.get();
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
break;
|
||||
|
||||
unsigned recordID = Cursor.skipRecord(entry.ID);
|
||||
switch (recordID) {
|
||||
Expected<unsigned> maybeRecordID = Cursor.skipRecord(entry.ID);
|
||||
if (!maybeRecordID)
|
||||
return maybeRecordID.takeError();
|
||||
switch (maybeRecordID.get()) {
|
||||
case GENERIC_REQUIREMENT:
|
||||
case LAYOUT_REQUIREMENT:
|
||||
break;
|
||||
|
||||
default:
|
||||
// This record is not a generic requirement.
|
||||
return;
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
lastRecordOffset.reset();
|
||||
}
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
GenericSignature ModuleFile::getGenericSignature(
|
||||
@@ -880,18 +899,20 @@ ModuleFile::getGenericSignatureChecked(serialization::GenericSignatureID ID) {
|
||||
|
||||
// Read the generic signature.
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(sigOffset);
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(sigOffset));
|
||||
|
||||
// Read the parameter types.
|
||||
SmallVector<GenericTypeParamType *, 4> paramTypes;
|
||||
StringRef blobData;
|
||||
SmallVector<uint64_t, 8> scratch;
|
||||
|
||||
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch, &blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
switch (recordID) {
|
||||
case GENERIC_SIGNATURE: {
|
||||
ArrayRef<uint64_t> rawParamIDs;
|
||||
@@ -903,6 +924,7 @@ ModuleFile::getGenericSignatureChecked(serialization::GenericSignatureID ID) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SIL_GENERIC_SIGNATURE: {
|
||||
ArrayRef<uint64_t> rawParamIDs;
|
||||
SILGenericSignatureLayout::readRecord(scratch, rawParamIDs);
|
||||
@@ -978,16 +1000,18 @@ ModuleFile::getSubstitutionMapChecked(serialization::SubstitutionMapID id) {
|
||||
|
||||
// Read the substitution map.
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(substitutionsOrOffset);
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(substitutionsOrOffset));
|
||||
|
||||
// Read the substitution map.
|
||||
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
StringRef blobData;
|
||||
SmallVector<uint64_t, 8> scratch;
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch, &blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
if (recordID != SUBSTITUTION_MAP)
|
||||
fatal();
|
||||
|
||||
@@ -1032,13 +1056,15 @@ ModuleFile::getSubstitutionMapChecked(serialization::SubstitutionMapID id) {
|
||||
bool ModuleFile::readDefaultWitnessTable(ProtocolDecl *proto) {
|
||||
using namespace decls_block;
|
||||
|
||||
auto entry = DeclTypeCursor.advance();
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
return true;
|
||||
|
||||
SmallVector<uint64_t, 16> witnessIDBuffer;
|
||||
|
||||
unsigned kind = DeclTypeCursor.readRecord(entry.ID, witnessIDBuffer);
|
||||
unsigned kind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(entry.ID, witnessIDBuffer));
|
||||
assert(kind == DEFAULT_WITNESS_TABLE);
|
||||
(void)kind;
|
||||
|
||||
@@ -1188,7 +1214,8 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
|
||||
assert(baseModule && "missing dependency");
|
||||
PrettyXRefTrace pathTrace(*baseModule);
|
||||
|
||||
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
@@ -1201,8 +1228,8 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
|
||||
// In particular, operator path pieces represent actual operators here, but
|
||||
// filters on operator functions when they appear later on.
|
||||
scratch.clear();
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
switch (recordID) {
|
||||
case XREF_TYPE_PATH_PIECE:
|
||||
case XREF_VALUE_PATH_PIECE: {
|
||||
@@ -1230,7 +1257,7 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
|
||||
auto maybeType = getTypeChecked(TID);
|
||||
if (!maybeType) {
|
||||
// FIXME: Don't throw away the inner error's information.
|
||||
llvm::consumeError(maybeType.takeError());
|
||||
consumeError(maybeType.takeError());
|
||||
return llvm::make_error<XRefError>("couldn't decode type",
|
||||
pathTrace, name);
|
||||
}
|
||||
@@ -1304,13 +1331,14 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
|
||||
auto getXRefDeclNameForError = [&]() -> DeclName {
|
||||
DeclName result = pathTrace.getLastName();
|
||||
while (--pathLen) {
|
||||
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
return Identifier();
|
||||
|
||||
scratch.clear();
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
switch (recordID) {
|
||||
case XREF_TYPE_PATH_PIECE: {
|
||||
IdentifierID IID;
|
||||
@@ -1373,13 +1401,14 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
|
||||
|
||||
// For remaining path pieces, filter or drill down into the results we have.
|
||||
while (--pathLen) {
|
||||
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
scratch.clear();
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
switch (recordID) {
|
||||
case XREF_TYPE_PATH_PIECE: {
|
||||
if (values.size() == 1 && isa<NominalTypeDecl>(values.front())) {
|
||||
@@ -1485,7 +1514,7 @@ giveUpFastPath:
|
||||
auto maybeType = getTypeChecked(TID);
|
||||
if (!maybeType) {
|
||||
// FIXME: Don't throw away the inner error's information.
|
||||
llvm::consumeError(maybeType.takeError());
|
||||
consumeError(maybeType.takeError());
|
||||
return llvm::make_error<XRefError>("couldn't decode type",
|
||||
pathTrace, memberName);
|
||||
}
|
||||
@@ -1776,8 +1805,8 @@ DeclContext *ModuleFile::getLocalDeclContext(LocalDeclContextID DCID) {
|
||||
return declContextOrOffset;
|
||||
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(declContextOrOffset);
|
||||
auto entry = DeclTypeCursor.advance();
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(declContextOrOffset));
|
||||
llvm::BitstreamEntry entry = fatalIfUnexpected(DeclTypeCursor.advance());
|
||||
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
@@ -1786,8 +1815,8 @@ DeclContext *ModuleFile::getLocalDeclContext(LocalDeclContextID DCID) {
|
||||
SmallVector<uint64_t, 64> scratch;
|
||||
StringRef blobData;
|
||||
|
||||
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = fatalIfUnexpected(
|
||||
DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
switch(recordID) {
|
||||
case decls_block::ABSTRACT_CLOSURE_EXPR_CONTEXT: {
|
||||
TypeID closureTypeID;
|
||||
@@ -3218,7 +3247,8 @@ public:
|
||||
|
||||
proto->setLazyRequirementSignature(&MF,
|
||||
MF.DeclTypeCursor.GetCurrentBitNo());
|
||||
skipGenericRequirements(MF.DeclTypeCursor);
|
||||
if (llvm::Error Err = skipGenericRequirements(MF.DeclTypeCursor))
|
||||
MF.fatal(std::move(Err));
|
||||
|
||||
proto->setMemberLoader(&MF, MF.DeclTypeCursor.GetCurrentBitNo());
|
||||
|
||||
@@ -3835,7 +3865,7 @@ ModuleFile::getDeclChecked(DeclID DID) {
|
||||
if (!declOrOffset.isComplete()) {
|
||||
++NumDeclsLoaded;
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(declOrOffset);
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(declOrOffset));
|
||||
|
||||
Expected<Decl *> deserialized =
|
||||
DeclDeserializer(*this, declOrOffset).getDeclCheckedImpl();
|
||||
@@ -3863,14 +3893,15 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
|
||||
StringRef blobData;
|
||||
while (true) {
|
||||
BCOffsetRAII restoreOffset(MF.DeclTypeCursor);
|
||||
auto entry = MF.DeclTypeCursor.advance();
|
||||
llvm::BitstreamEntry entry =
|
||||
MF.fatalIfUnexpected(MF.DeclTypeCursor.advance());
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record) {
|
||||
// We don't know how to serialize decls represented by sub-blocks.
|
||||
MF.fatal();
|
||||
}
|
||||
|
||||
unsigned recordID = MF.DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = MF.fatalIfUnexpected(
|
||||
MF.DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
|
||||
if (isDeclAttrRecord(recordID)) {
|
||||
DeclAttribute *Attr = nullptr;
|
||||
@@ -4164,7 +4195,8 @@ DeclDeserializer::getDeclCheckedImpl() {
|
||||
if (declOrOffset.isComplete())
|
||||
return declOrOffset;
|
||||
|
||||
auto entry = MF.DeclTypeCursor.advance();
|
||||
llvm::BitstreamEntry entry =
|
||||
MF.fatalIfUnexpected(MF.DeclTypeCursor.advance());
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record) {
|
||||
// We don't know how to serialize decls represented by sub-blocks.
|
||||
MF.fatal();
|
||||
@@ -4172,8 +4204,8 @@ DeclDeserializer::getDeclCheckedImpl() {
|
||||
|
||||
SmallVector<uint64_t, 64> scratch;
|
||||
StringRef blobData;
|
||||
unsigned recordID = MF.DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = MF.fatalIfUnexpected(
|
||||
MF.DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
|
||||
PrettyDeclDeserialization stackTraceEntry(
|
||||
&MF, declOrOffset, static_cast<decls_block::RecordKind>(recordID));
|
||||
@@ -4567,13 +4599,14 @@ public:
|
||||
// The tuple record itself is empty. Read all trailing elements.
|
||||
SmallVector<TupleTypeElt, 8> elements;
|
||||
while (true) {
|
||||
auto entry = MF.DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
MF.fatalIfUnexpected(MF.DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
break;
|
||||
|
||||
scratch.clear();
|
||||
unsigned recordID = MF.DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = MF.fatalIfUnexpected(
|
||||
MF.DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
if (recordID != decls_block::TUPLE_TYPE_ELT)
|
||||
break;
|
||||
|
||||
@@ -4627,13 +4660,14 @@ public:
|
||||
|
||||
SmallVector<AnyFunctionType::Param, 8> params;
|
||||
while (true) {
|
||||
auto entry = MF.DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry entry =
|
||||
MF.fatalIfUnexpected(MF.DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
break;
|
||||
|
||||
scratch.clear();
|
||||
unsigned recordID = MF.DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = MF.fatalIfUnexpected(
|
||||
MF.DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
if (recordID != decls_block::FUNCTION_PARAM)
|
||||
break;
|
||||
|
||||
@@ -4922,7 +4956,7 @@ public:
|
||||
}
|
||||
|
||||
BCOffsetRAII saveOffset(MF.DeclTypeCursor);
|
||||
MF.DeclTypeCursor.JumpToBit(layoutOrOffset);
|
||||
MF.fatalIfNotSuccess(MF.DeclTypeCursor.JumpToBit(layoutOrOffset));
|
||||
auto layout = MF.readSILLayout(MF.DeclTypeCursor);
|
||||
if (!layout)
|
||||
MF.fatal();
|
||||
@@ -5160,7 +5194,7 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
|
||||
return typeOrOffset;
|
||||
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(typeOrOffset);
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(typeOrOffset));
|
||||
|
||||
auto result = TypeDeserializer(*this).getTypeCheckedImpl();
|
||||
if (!result)
|
||||
@@ -5185,7 +5219,8 @@ Expected<Type> TypeDeserializer::getTypeCheckedImpl() {
|
||||
if (auto s = ctx.Stats)
|
||||
s->getFrontendCounters().NumTypesDeserialized++;
|
||||
|
||||
auto entry = MF.DeclTypeCursor.advance();
|
||||
llvm::BitstreamEntry entry =
|
||||
MF.fatalIfUnexpected(MF.DeclTypeCursor.advance());
|
||||
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record) {
|
||||
// We don't know how to serialize types represented by sub-blocks.
|
||||
@@ -5194,8 +5229,8 @@ Expected<Type> TypeDeserializer::getTypeCheckedImpl() {
|
||||
|
||||
SmallVector<uint64_t, 64> scratch;
|
||||
StringRef blobData;
|
||||
unsigned recordID = MF.DeclTypeCursor.readRecord(entry.ID, scratch,
|
||||
&blobData);
|
||||
unsigned recordID = MF.fatalIfUnexpected(
|
||||
MF.DeclTypeCursor.readRecord(entry.ID, scratch, &blobData));
|
||||
|
||||
switch (recordID) {
|
||||
#define CASE(RECORD_NAME) \
|
||||
@@ -5307,14 +5342,15 @@ void ModuleFile::loadAllMembers(Decl *container, uint64_t contextData) {
|
||||
IDC = cast<ExtensionDecl>(container);
|
||||
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(contextData);
|
||||
auto entry = DeclTypeCursor.advance();
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(contextData));
|
||||
llvm::BitstreamEntry entry = fatalIfUnexpected(DeclTypeCursor.advance());
|
||||
if (entry.Kind != llvm::BitstreamEntry::Record)
|
||||
fatal();
|
||||
|
||||
SmallVector<uint64_t, 16> memberIDBuffer;
|
||||
|
||||
unsigned kind = DeclTypeCursor.readRecord(entry.ID, memberIDBuffer);
|
||||
unsigned kind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(entry.ID, memberIDBuffer));
|
||||
assert(kind == decls_block::MEMBERS);
|
||||
(void)kind;
|
||||
|
||||
@@ -5364,7 +5400,7 @@ ModuleFile::loadAllConformances(const Decl *D, uint64_t contextData,
|
||||
= decodeLazyConformanceContextData(contextData);
|
||||
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(bitPosition);
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(bitPosition));
|
||||
|
||||
while (numConformances--) {
|
||||
auto conf = readConformance(DeclTypeCursor);
|
||||
@@ -5396,8 +5432,8 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
|
||||
|
||||
// Find the conformance record.
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(contextData);
|
||||
auto entry = DeclTypeCursor.advance();
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(contextData));
|
||||
llvm::BitstreamEntry entry = fatalIfUnexpected(DeclTypeCursor.advance());
|
||||
assert(entry.Kind == llvm::BitstreamEntry::Record &&
|
||||
"registered lazy loader incorrectly");
|
||||
|
||||
@@ -5407,7 +5443,8 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
|
||||
ArrayRef<uint64_t> rawIDs;
|
||||
SmallVector<uint64_t, 16> scratch;
|
||||
|
||||
unsigned kind = DeclTypeCursor.readRecord(entry.ID, scratch);
|
||||
unsigned kind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(entry.ID, scratch));
|
||||
(void) kind;
|
||||
assert(kind == NORMAL_PROTOCOL_CONFORMANCE &&
|
||||
"registered lazy loader incorrectly");
|
||||
@@ -5598,7 +5635,7 @@ void ModuleFile::loadRequirementSignature(const ProtocolDecl *decl,
|
||||
uint64_t contextData,
|
||||
SmallVectorImpl<Requirement> &reqs) {
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
DeclTypeCursor.JumpToBit(contextData);
|
||||
fatalIfNotSuccess(DeclTypeCursor.JumpToBit(contextData));
|
||||
readGenericRequirements(reqs, DeclTypeCursor);
|
||||
}
|
||||
|
||||
@@ -5627,11 +5664,13 @@ Optional<StringRef> ModuleFile::maybeReadInlinableBodyText() {
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
StringRef blobData;
|
||||
|
||||
auto next = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry next =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (next.Kind != llvm::BitstreamEntry::Record)
|
||||
return None;
|
||||
|
||||
unsigned recKind = DeclTypeCursor.readRecord(next.ID, scratch, &blobData);
|
||||
unsigned recKind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(next.ID, scratch, &blobData));
|
||||
if (recKind != INLINABLE_BODY_TEXT)
|
||||
return None;
|
||||
|
||||
@@ -5646,11 +5685,13 @@ Optional<ForeignErrorConvention> ModuleFile::maybeReadForeignErrorConvention() {
|
||||
|
||||
BCOffsetRAII restoreOffset(DeclTypeCursor);
|
||||
|
||||
auto next = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
|
||||
llvm::BitstreamEntry next =
|
||||
fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd));
|
||||
if (next.Kind != llvm::BitstreamEntry::Record)
|
||||
return None;
|
||||
|
||||
unsigned recKind = DeclTypeCursor.readRecord(next.ID, scratch);
|
||||
unsigned recKind =
|
||||
fatalIfUnexpected(DeclTypeCursor.readRecord(next.ID, scratch));
|
||||
switch (recKind) {
|
||||
case FOREIGN_ERROR_CONVENTION:
|
||||
restoreOffset.reset();
|
||||
|
||||
Reference in New Issue
Block a user