@@ -862,14 +862,16 @@ static ValueDecl *getRefCountingOperation(ASTContext &ctx, Identifier id) {
862
862
static ValueDecl *getLoadOperation (ASTContext &ctx, Identifier id) {
863
863
return getBuiltinFunction (ctx, id, _thin,
864
864
_generics (_unrestricted,
865
- _conformsTo (_typeparam (0 ), _copyable)),
865
+ _conformsTo (_typeparam (0 ), _copyable),
866
+ _conformsTo (_typeparam (0 ), _escapable)),
866
867
_parameters (_rawPointer),
867
868
_typeparam (0 ));
868
869
}
869
870
870
871
static ValueDecl *getTakeOperation (ASTContext &ctx, Identifier id) {
871
872
return getBuiltinFunction (ctx, id, _thin,
872
- _generics (_unrestricted),
873
+ _generics (_unrestricted,
874
+ _conformsTo (_typeparam (0 ), _escapable)),
873
875
_parameters (_rawPointer),
874
876
_typeparam (0 ));
875
877
}
@@ -902,7 +904,8 @@ static ValueDecl *getDestroyArrayOperation(ASTContext &ctx, Identifier id) {
902
904
static ValueDecl *getCopyOperation (ASTContext &ctx, Identifier id) {
903
905
return getBuiltinFunction (ctx, id, _thin,
904
906
_generics (_unrestricted,
905
- _conformsTo (_typeparam (0 ), _copyable)),
907
+ _conformsTo (_typeparam (0 ), _copyable),
908
+ _conformsTo (_typeparam (0 ), _escapable)),
906
909
_parameters (_typeparam (0 )), _typeparam (0 ));
907
910
}
908
911
@@ -976,12 +979,16 @@ static ValueDecl *getAllocWithTailElemsOperation(ASTContext &Context,
976
979
1 + NumTailTypes > (int )std::size (GenericParamNames))
977
980
return nullptr ;
978
981
BuiltinFunctionBuilder builder (Context, 1 + NumTailTypes);
979
- builder.addParameter (makeMetatype (makeGenericParam (0 )));
982
+
983
+ auto resultTy = makeGenericParam (0 );
984
+ builder.addConformanceRequirement (resultTy, KnownProtocolKind::Escapable);
985
+
986
+ builder.addParameter (makeMetatype (resultTy));
980
987
for (int Idx = 0 ; Idx < NumTailTypes; ++Idx) {
981
988
builder.addParameter (makeConcrete (BuiltinIntegerType::getWordType (Context)));
982
989
builder.addParameter (makeMetatype (makeGenericParam (Idx + 1 )));
983
990
}
984
- builder.setResult (makeGenericParam ( 0 ) );
991
+ builder.setResult (resultTy );
985
992
return builder.build (Id);
986
993
}
987
994
@@ -1262,6 +1269,7 @@ static ValueDecl *getCOWBufferForReading(ASTContext &C, Identifier Id) {
1262
1269
//
1263
1270
BuiltinFunctionBuilder builder (C, 1 , true );
1264
1271
auto T = makeGenericParam ();
1272
+ builder.addConformanceRequirement (T, KnownProtocolKind::Escapable);
1265
1273
builder.addParameter (T);
1266
1274
builder.setResult (T);
1267
1275
return builder.build (Id);
@@ -1286,7 +1294,11 @@ static ValueDecl *getCastReferenceOperation(ASTContext &ctx,
1286
1294
// SILGen and IRGen check additional constraints during lowering.
1287
1295
BuiltinFunctionBuilder builder (ctx, 2 );
1288
1296
builder.addParameter (makeGenericParam (0 ), ParamSpecifier::LegacyOwned);
1289
- builder.setResult (makeGenericParam (1 ));
1297
+
1298
+ auto resultTy = makeGenericParam (1 );
1299
+ builder.addConformanceRequirement (resultTy, KnownProtocolKind::Escapable);
1300
+ builder.setResult (resultTy);
1301
+
1290
1302
return builder.build (name);
1291
1303
}
1292
1304
@@ -1296,7 +1308,11 @@ static ValueDecl *getReinterpretCastOperation(ASTContext &ctx,
1296
1308
// SILGen and IRGen check additional constraints during lowering.
1297
1309
BuiltinFunctionBuilder builder (ctx, 2 );
1298
1310
builder.addParameter (makeGenericParam (0 ), ParamSpecifier::LegacyOwned);
1299
- builder.setResult (makeGenericParam (1 ));
1311
+
1312
+ auto resultTy = makeGenericParam (1 );
1313
+ builder.addConformanceRequirement (resultTy, KnownProtocolKind::Escapable);
1314
+ builder.setResult (resultTy);
1315
+
1300
1316
return builder.build (name);
1301
1317
}
1302
1318
@@ -1485,7 +1501,11 @@ static ValueDecl *getConvertUnownedUnsafeToGuaranteed(ASTContext &ctx,
1485
1501
BuiltinFunctionBuilder builder (ctx, 3 );
1486
1502
builder.addParameter (makeGenericParam (0 )); // Base
1487
1503
builder.addParameter (makeGenericParam (1 ), ParamSpecifier::InOut); // Unmanaged
1488
- builder.setResult (makeGenericParam (2 )); // Guaranteed Result
1504
+
1505
+ auto resultTy = makeGenericParam (2 );
1506
+ builder.addConformanceRequirement (resultTy, KnownProtocolKind::Escapable);
1507
+ builder.setResult (resultTy); // Guaranteed Result
1508
+
1489
1509
return builder.build (id);
1490
1510
}
1491
1511
0 commit comments