Skip to content

Commit f3dd7f7

Browse files
authored
Merge pull request #40808 from CodaFi/standing-room-only
Propagate Pattern Arena When Allocating PackExpansionTypes
2 parents a4fe57f + 659e145 commit f3dd7f7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/AST/ASTContext.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ struct ASTContext::Implementation {
389389
llvm::FoldingSet<TypeAliasType> TypeAliasTypes;
390390
llvm::FoldingSet<TupleType> TupleTypes;
391391
llvm::FoldingSet<PackType> PackTypes;
392+
llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
392393
llvm::DenseMap<llvm::PointerIntPair<TypeBase*, 3, unsigned>,
393394
MetatypeType*> MetatypeTypes;
394395
llvm::DenseMap<llvm::PointerIntPair<TypeBase*, 3, unsigned>,
@@ -471,7 +472,6 @@ struct ASTContext::Implementation {
471472
llvm::FoldingSet<SILBoxType> SILBoxTypes;
472473
llvm::DenseMap<BuiltinIntegerWidth, BuiltinIntegerType*> IntegerTypes;
473474
llvm::FoldingSet<BuiltinVectorType> BuiltinVectorTypes;
474-
llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
475475
llvm::FoldingSet<DeclName::CompoundDeclName> CompoundNames;
476476
llvm::DenseMap<UUID, OpenedArchetypeType *> OpenedExistentialArchetypes;
477477
llvm::FoldingSet<IndexSubset> IndexSubsets;
@@ -2960,20 +2960,25 @@ Type TupleTypeElt::getType() const {
29602960
PackExpansionType *PackExpansionType::get(Type patternTy) {
29612961
assert(patternTy && "Missing pattern type in expansion");
29622962

2963+
auto properties = patternTy->getRecursiveProperties();
2964+
auto arena = getArena(properties);
2965+
29632966
auto &context = patternTy->getASTContext();
29642967
llvm::FoldingSetNodeID id;
29652968
PackExpansionType::Profile(id, patternTy);
29662969

29672970
void *insertPos;
29682971
if (PackExpansionType *expType =
2969-
context.getImpl().PackExpansionTypes.FindNodeOrInsertPos(id,
2970-
insertPos))
2972+
context.getImpl()
2973+
.getArena(arena)
2974+
.PackExpansionTypes.FindNodeOrInsertPos(id, insertPos))
29712975
return expType;
29722976

29732977
const ASTContext *canCtx = patternTy->isCanonical() ? &context : nullptr;
29742978
PackExpansionType *expansionTy = new (context, AllocationArena::Permanent)
29752979
PackExpansionType(patternTy, canCtx);
2976-
context.getImpl().PackExpansionTypes.InsertNode(expansionTy, insertPos);
2980+
context.getImpl().getArena(arena).PackExpansionTypes.InsertNode(expansionTy,
2981+
insertPos);
29772982
return expansionTy;
29782983
}
29792984

0 commit comments

Comments
 (0)