Skip to content

Commit 0bc0bf5

Browse files
xedinhamishknight
authored andcommitted
[CSClosure] Allocate temporary type-join and opaque value exprs in solver arena
(cherry picked from commit f3df7ab)
1 parent 5fbc51c commit 0bc0bf5

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

include/swift/AST/Expr.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,6 +4350,10 @@ class OpaqueValueExpr : public Expr {
43504350
Bits.OpaqueValueExpr.IsPlaceholder = isPlaceholder;
43514351
}
43524352

4353+
static OpaqueValueExpr *
4354+
createImplicit(ASTContext &ctx, Type Ty, bool isPlaceholder = false,
4355+
AllocationArena arena = AllocationArena::Permanent);
4356+
43534357
/// Whether this opaque value expression represents a placeholder that
43544358
/// is injected before type checking to act as a placeholder for some
43554359
/// value to be specified later.
@@ -6012,17 +6016,20 @@ class TypeJoinExpr final : public Expr,
60126016
static TypeJoinExpr *
60136017
createImpl(ASTContext &ctx,
60146018
llvm::PointerUnion<DeclRefExpr *, TypeBase *> varOrType,
6015-
ArrayRef<Expr *> elements);
6019+
ArrayRef<Expr *> elements,
6020+
AllocationArena arena = AllocationArena::Permanent);
60166021

60176022
public:
6018-
static TypeJoinExpr *create(ASTContext &ctx, DeclRefExpr *var,
6019-
ArrayRef<Expr *> exprs) {
6020-
return createImpl(ctx, var, exprs);
6023+
static TypeJoinExpr *
6024+
create(ASTContext &ctx, DeclRefExpr *var, ArrayRef<Expr *> exprs,
6025+
AllocationArena arena = AllocationArena::Permanent) {
6026+
return createImpl(ctx, var, exprs, arena);
60216027
}
60226028

6023-
static TypeJoinExpr *create(ASTContext &ctx, Type joinType,
6024-
ArrayRef<Expr *> exprs) {
6025-
return createImpl(ctx, joinType.getPointer(), exprs);
6029+
static TypeJoinExpr *
6030+
create(ASTContext &ctx, Type joinType, ArrayRef<Expr *> exprs,
6031+
AllocationArena arena = AllocationArena::Permanent) {
6032+
return createImpl(ctx, joinType.getPointer(), exprs, arena);
60266033
}
60276034

60286035
SourceLoc getLoc() const { return SourceLoc(); }

lib/AST/Expr.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,15 @@ static ValueDecl *getCalledValue(Expr *E, bool skipFunctionConversions) {
15251525
return nullptr;
15261526
}
15271527

1528+
OpaqueValueExpr *OpaqueValueExpr::createImplicit(ASTContext &ctx, Type Ty,
1529+
bool isPlaceholder,
1530+
AllocationArena arena) {
1531+
auto *mem =
1532+
ctx.Allocate(sizeof(OpaqueValueExpr), alignof(OpaqueValueExpr), arena);
1533+
return new (mem) OpaqueValueExpr(
1534+
/*Range=*/SourceRange(), Ty, isPlaceholder);
1535+
}
1536+
15281537
PropertyWrapperValuePlaceholderExpr *
15291538
PropertyWrapperValuePlaceholderExpr::create(ASTContext &ctx, SourceRange range,
15301539
Type ty, Expr *wrappedValue,
@@ -2481,9 +2490,9 @@ TypeJoinExpr::TypeJoinExpr(llvm::PointerUnion<DeclRefExpr *, TypeBase *> result,
24812490

24822491
TypeJoinExpr *TypeJoinExpr::createImpl(
24832492
ASTContext &ctx, llvm::PointerUnion<DeclRefExpr *, TypeBase *> varOrType,
2484-
ArrayRef<Expr *> elements) {
2493+
ArrayRef<Expr *> elements, AllocationArena arena) {
24852494
size_t size = totalSizeToAlloc<Expr *>(elements.size());
2486-
void *mem = ctx.Allocate(size, alignof(TypeJoinExpr));
2495+
void *mem = ctx.Allocate(size, alignof(TypeJoinExpr), arena);
24872496
return new (mem) TypeJoinExpr(varOrType, elements);
24882497
}
24892498

0 commit comments

Comments
 (0)