@@ -782,6 +782,23 @@ static ValueDecl *getCastFromBridgeObjectOperation(ASTContext &C,
782
782
}
783
783
}
784
784
785
+ static ValueDecl *getUnsafeGuaranteed (ASTContext &C, Identifier Id) {
786
+ // <T : AnyObject> T -> (T, Int8Ty)
787
+ //
788
+ GenericSignatureBuilder builder (C);
789
+ auto T = makeGenericParam ();
790
+ builder.addParameter (T);
791
+ Type Int8Ty = BuiltinIntegerType::get (8 , C);
792
+ builder.setResult (makeTuple (T, makeConcrete (Int8Ty)));
793
+ return builder.build (Id);
794
+ }
795
+
796
+ static ValueDecl *getUnsafeGuaranteedEnd (ASTContext &C, Identifier Id) {
797
+ // Int8Ty -> ()
798
+ Type Int8Ty = BuiltinIntegerType::get (8 , C);
799
+ return getBuiltinFunction (Id, { Int8Ty }, TupleType::getEmpty (C));
800
+ }
801
+
785
802
static ValueDecl *getCastReferenceOperation (ASTContext &ctx,
786
803
Identifier name) {
787
804
// <T, U> T -> U
@@ -1574,10 +1591,17 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
1574
1591
if (Types.size () != 1 ) return nullptr ;
1575
1592
return getCheckedConversionOperation (Context, Id, Types[0 ]);
1576
1593
1594
+ case BuiltinValueKind::UnsafeGuaranteed:
1595
+ return getUnsafeGuaranteed (Context, Id);
1596
+
1597
+ case BuiltinValueKind::UnsafeGuaranteedEnd:
1598
+ return getUnsafeGuaranteedEnd (Context, Id);
1599
+
1577
1600
case BuiltinValueKind::IntToFPWithOverflow:
1578
1601
if (Types.size () != 2 ) return nullptr ;
1579
1602
return getIntToFPWithOverflowOperation (Context, Id, Types[0 ], Types[1 ]);
1580
1603
}
1604
+
1581
1605
llvm_unreachable (" bad builtin value!" );
1582
1606
}
1583
1607
0 commit comments