Skip to content

Commit 0816496

Browse files
committed
Serialization: Bubble up more errors under readSILFunctionChecked
rdar://131414533
1 parent fb0a1b9 commit 0816496

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@
5555

5656
#define DEBUG_TYPE "Serialization"
5757

58-
// Unwrap an Expected<> variable following the typical deserialization pattern:
59-
// - On a value, assign it to Output.
60-
// - On an error, return it to bubble it up to the caller.
61-
#define UNWRAP(Input, Output) { \
62-
auto ValueOrError = Input; \
63-
if (!ValueOrError) \
64-
return ValueOrError.takeError(); \
65-
Output = ValueOrError.get(); \
66-
}
67-
6858
STATISTIC(NumDeclsLoaded, "# of decls deserialized");
6959
STATISTIC(NumMemberListsLoaded,
7060
"# of nominals/extensions whose members were loaded");

lib/Serialization/DeserializationErrors.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
#include "llvm/Support/Error.h"
2222
#include "llvm/Support/PrettyStackTrace.h"
2323

24+
// Unwrap an Expected<> variable following the typical deserialization pattern:
25+
// - On a value, assign it to Output.
26+
// - On an error, return it to bubble it up to the caller.
27+
#define UNWRAP(Input, Output) { \
28+
auto ValueOrError = Input; \
29+
if (!ValueOrError) \
30+
return ValueOrError.takeError(); \
31+
Output = ValueOrError.get(); \
32+
}
33+
2434
namespace swift {
2535
namespace serialization {
2636

lib/Serialization/DeserializeSIL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,9 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
625625

626626
ValueDecl *clangNodeOwner = nullptr;
627627
if (clangNodeOwnerID != 0) {
628-
clangNodeOwner = dyn_cast_or_null<ValueDecl>(MF->getDecl(clangNodeOwnerID));
628+
Decl *clangNodeOwnerDecl;
629+
UNWRAP(MF->getDeclChecked(clangNodeOwnerID), clangNodeOwnerDecl);
630+
clangNodeOwner = dyn_cast_or_null<ValueDecl>(clangNodeOwnerDecl);
629631
if (!clangNodeOwner)
630632
return MF->diagnoseFatal("invalid clang node owner for SILFunction");
631633
}

0 commit comments

Comments
 (0)