@@ -2234,6 +2234,7 @@ class swift::DeclDeserializer {
2234
2234
using TypeID = serialization::TypeID;
2235
2235
2236
2236
ModuleFile &MF;
2237
+ ASTContext &ctx;
2237
2238
Serialized<Decl *> &declOrOffset;
2238
2239
2239
2240
DeclAttribute *DAttrs = nullptr ;
@@ -2252,9 +2253,18 @@ class swift::DeclDeserializer {
2252
2253
AttrsNext = Attr->getMutableNext ();
2253
2254
};
2254
2255
2256
+ void handleInherited (TypeDecl *nominal, ArrayRef<uint64_t > rawInheritedIDs) {
2257
+ auto inheritedTypes = ctx.Allocate <TypeLoc>(rawInheritedIDs.size ());
2258
+ for_each (inheritedTypes, rawInheritedIDs,
2259
+ [this ](TypeLoc &tl, uint64_t rawID) {
2260
+ tl = TypeLoc::withoutLoc (MF.getType (rawID));
2261
+ });
2262
+ nominal->setInherited (inheritedTypes);
2263
+ }
2264
+
2255
2265
public:
2256
2266
DeclDeserializer (ModuleFile &MF, Serialized<Decl *> &declOrOffset)
2257
- : MF(MF), declOrOffset(declOrOffset) {}
2267
+ : MF(MF), ctx(MF.getContext()), declOrOffset(declOrOffset) {}
2258
2268
2259
2269
~DeclDeserializer () {
2260
2270
if (!declOrOffset.isComplete ()) {
@@ -2377,7 +2387,6 @@ static bool attributeChainContains(DeclAttribute *attr) {
2377
2387
llvm::Error DeclDeserializer::deserializeDeclAttributes () {
2378
2388
using namespace decls_block ;
2379
2389
2380
- ASTContext &ctx = MF.getContext ();
2381
2390
SmallVector<uint64_t , 64 > scratch;
2382
2391
StringRef blobData;
2383
2392
while (true ) {
@@ -2668,22 +2677,9 @@ DeclDeserializer::getDeclCheckedImpl(ModuleFile &MF, DeclID DID) {
2668
2677
2669
2678
Expected<Decl *>
2670
2679
DeclDeserializer::getDeclCheckedImpl () {
2671
- ASTContext &ctx = MF.getContext ();
2672
-
2673
2680
if (auto s = ctx.Stats )
2674
2681
s->getFrontendCounters ().NumDeclsDeserialized ++;
2675
2682
2676
- // Local function that handles the "inherited" list for a type.
2677
- auto handleInherited
2678
- = [&](TypeDecl *nominal, ArrayRef<uint64_t > rawInheritedIDs) {
2679
- auto inheritedTypes = ctx.Allocate <TypeLoc>(rawInheritedIDs.size ());
2680
- for_each (inheritedTypes, rawInheritedIDs,
2681
- [this ](TypeLoc &tl, uint64_t rawID) {
2682
- tl = TypeLoc::withoutLoc (MF.getType (rawID));
2683
- });
2684
- nominal->setInherited (inheritedTypes);
2685
- };
2686
-
2687
2683
auto attrError = deserializeDeclAttributes ();
2688
2684
if (attrError)
2689
2685
return std::move (attrError);
0 commit comments