@@ -2309,7 +2309,6 @@ class swift::DeclDeserializer {
2309
2309
// / passing each one to AddAttribute.
2310
2310
llvm::Error deserializeDeclAttributes ();
2311
2311
2312
- static Expected<Decl *> getDeclCheckedImpl (ModuleFile &MF, DeclID DID);
2313
2312
Expected<Decl *> getDeclCheckedImpl ();
2314
2313
2315
2314
Expected<Decl *> deserializeTypeAlias (ArrayRef<uint64_t > scratch,
@@ -3767,19 +3766,34 @@ class swift::DeclDeserializer {
3767
3766
Expected<Decl *>
3768
3767
ModuleFile::getDeclChecked (DeclID DID) {
3769
3768
// Tag every deserialized ValueDecl coming out of getDeclChecked with its ID.
3770
- Expected<Decl *> deserialized =
3771
- DeclDeserializer::getDeclCheckedImpl (*this , DID);
3772
- if (deserialized && deserialized.get ()) {
3773
- if (auto *IDC = dyn_cast<IterableDeclContext>(deserialized.get ())) {
3769
+ if (DID == 0 )
3770
+ return nullptr ;
3771
+
3772
+ assert (DID <= Decls.size () && " invalid decl ID" );
3773
+ auto &declOrOffset = Decls[DID-1 ];
3774
+
3775
+ if (declOrOffset.isComplete ())
3776
+ return declOrOffset;
3777
+
3778
+ ++NumDeclsLoaded;
3779
+ BCOffsetRAII restoreOffset (DeclTypeCursor);
3780
+ DeclTypeCursor.JumpToBit (declOrOffset);
3781
+
3782
+ SWIFT_DEFER {
3783
+ if (!declOrOffset.isComplete ())
3784
+ return ;
3785
+ if (auto *IDC = dyn_cast_or_null<IterableDeclContext>(declOrOffset.get ())) {
3774
3786
// Only set the DeclID on the returned Decl if it's one that was loaded
3775
3787
// and _wasn't_ one that had its DeclID set elsewhere (a followed XREF).
3776
3788
if (IDC->wasDeserialized () &&
3777
3789
static_cast <uint32_t >(IDC->getDeclID ()) == 0 ) {
3778
3790
IDC->setDeclID (DID);
3779
3791
}
3780
3792
}
3781
- }
3782
- return deserialized;
3793
+ };
3794
+
3795
+ ModuleFile::DeserializingEntityRAII deserializingEntity (*this );
3796
+ return DeclDeserializer (*this , declOrOffset).getDeclCheckedImpl ();
3783
3797
}
3784
3798
3785
3799
llvm::Error DeclDeserializer::deserializeDeclAttributes () {
@@ -4054,25 +4068,6 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
4054
4068
}
4055
4069
}
4056
4070
4057
- Expected<Decl *>
4058
- DeclDeserializer::getDeclCheckedImpl (ModuleFile &MF, DeclID DID) {
4059
- if (DID == 0 )
4060
- return nullptr ;
4061
-
4062
- assert (DID <= MF.Decls .size () && " invalid decl ID" );
4063
- auto &declOrOffset = MF.Decls [DID-1 ];
4064
-
4065
- if (declOrOffset.isComplete ())
4066
- return declOrOffset;
4067
-
4068
- ++NumDeclsLoaded;
4069
- BCOffsetRAII restoreOffset (MF.DeclTypeCursor );
4070
- MF.DeclTypeCursor .JumpToBit (declOrOffset);
4071
-
4072
- ModuleFile::DeserializingEntityRAII deserializingEntity (MF);
4073
- return DeclDeserializer (MF, declOrOffset).getDeclCheckedImpl ();
4074
- }
4075
-
4076
4071
Expected<Decl *>
4077
4072
DeclDeserializer::getDeclCheckedImpl () {
4078
4073
if (auto s = ctx.Stats )
0 commit comments