@@ -2309,7 +2309,6 @@ class swift::DeclDeserializer {
23092309 // / passing each one to AddAttribute.
23102310 llvm::Error deserializeDeclAttributes ();
23112311
2312- static Expected<Decl *> getDeclCheckedImpl (ModuleFile &MF, DeclID DID);
23132312 Expected<Decl *> getDeclCheckedImpl ();
23142313
23152314 Expected<Decl *> deserializeTypeAlias (ArrayRef<uint64_t > scratch,
@@ -3767,19 +3766,34 @@ class swift::DeclDeserializer {
37673766Expected<Decl *>
37683767ModuleFile::getDeclChecked (DeclID DID) {
37693768 // 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 ())) {
37743786 // Only set the DeclID on the returned Decl if it's one that was loaded
37753787 // and _wasn't_ one that had its DeclID set elsewhere (a followed XREF).
37763788 if (IDC->wasDeserialized () &&
37773789 static_cast <uint32_t >(IDC->getDeclID ()) == 0 ) {
37783790 IDC->setDeclID (DID);
37793791 }
37803792 }
3781- }
3782- return deserialized;
3793+ };
3794+
3795+ ModuleFile::DeserializingEntityRAII deserializingEntity (*this );
3796+ return DeclDeserializer (*this , declOrOffset).getDeclCheckedImpl ();
37833797}
37843798
37853799llvm::Error DeclDeserializer::deserializeDeclAttributes () {
@@ -4054,25 +4068,6 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
40544068 }
40554069}
40564070
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-
40764071Expected<Decl *>
40774072DeclDeserializer::getDeclCheckedImpl () {
40784073 if (auto s = ctx.Stats )
0 commit comments