Skip to content

Commit 2d1588a

Browse files
xedinhamishknight
authored andcommitted
[CSClosure] Allocate temporary type-join and opaque value exprs in solver arena
(cherry picked from commit f3df7ab)
1 parent 51b2481 commit 2d1588a

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
@@ -4360,6 +4360,10 @@ class OpaqueValueExpr : public Expr {
43604360
Bits.OpaqueValueExpr.IsPlaceholder = isPlaceholder;
43614361
}
43624362

4363+
static OpaqueValueExpr *
4364+
createImplicit(ASTContext &ctx, Type Ty, bool isPlaceholder = false,
4365+
AllocationArena arena = AllocationArena::Permanent);
4366+
43634367
/// Whether this opaque value expression represents a placeholder that
43644368
/// is injected before type checking to act as a placeholder for some
43654369
/// value to be specified later.
@@ -6022,17 +6026,20 @@ class TypeJoinExpr final : public Expr,
60226026
static TypeJoinExpr *
60236027
createImpl(ASTContext &ctx,
60246028
llvm::PointerUnion<DeclRefExpr *, TypeBase *> varOrType,
6025-
ArrayRef<Expr *> elements);
6029+
ArrayRef<Expr *> elements,
6030+
AllocationArena arena = AllocationArena::Permanent);
60266031

60276032
public:
6028-
static TypeJoinExpr *create(ASTContext &ctx, DeclRefExpr *var,
6029-
ArrayRef<Expr *> exprs) {
6030-
return createImpl(ctx, var, exprs);
6033+
static TypeJoinExpr *
6034+
create(ASTContext &ctx, DeclRefExpr *var, ArrayRef<Expr *> exprs,
6035+
AllocationArena arena = AllocationArena::Permanent) {
6036+
return createImpl(ctx, var, exprs, arena);
60316037
}
60326038

6033-
static TypeJoinExpr *create(ASTContext &ctx, Type joinType,
6034-
ArrayRef<Expr *> exprs) {
6035-
return createImpl(ctx, joinType.getPointer(), exprs);
6039+
static TypeJoinExpr *
6040+
create(ASTContext &ctx, Type joinType, ArrayRef<Expr *> exprs,
6041+
AllocationArena arena = AllocationArena::Permanent) {
6042+
return createImpl(ctx, joinType.getPointer(), exprs, arena);
60366043
}
60376044

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

lib/AST/Expr.cpp

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

1562+
OpaqueValueExpr *OpaqueValueExpr::createImplicit(ASTContext &ctx, Type Ty,
1563+
bool isPlaceholder,
1564+
AllocationArena arena) {
1565+
auto *mem =
1566+
ctx.Allocate(sizeof(OpaqueValueExpr), alignof(OpaqueValueExpr), arena);
1567+
return new (mem) OpaqueValueExpr(
1568+
/*Range=*/SourceRange(), Ty, isPlaceholder);
1569+
}
1570+
15621571
PropertyWrapperValuePlaceholderExpr *
15631572
PropertyWrapperValuePlaceholderExpr::create(ASTContext &ctx, SourceRange range,
15641573
Type ty, Expr *wrappedValue,
@@ -2540,9 +2549,9 @@ TypeJoinExpr::TypeJoinExpr(llvm::PointerUnion<DeclRefExpr *, TypeBase *> result,
25402549

25412550
TypeJoinExpr *TypeJoinExpr::createImpl(
25422551
ASTContext &ctx, llvm::PointerUnion<DeclRefExpr *, TypeBase *> varOrType,
2543-
ArrayRef<Expr *> elements) {
2552+
ArrayRef<Expr *> elements, AllocationArena arena) {
25442553
size_t size = totalSizeToAlloc<Expr *>(elements.size());
2545-
void *mem = ctx.Allocate(size, alignof(TypeJoinExpr));
2554+
void *mem = ctx.Allocate(size, alignof(TypeJoinExpr), arena);
25462555
return new (mem) TypeJoinExpr(varOrType, elements);
25472556
}
25482557

0 commit comments

Comments
 (0)