@@ -863,22 +863,19 @@ emitRValueForDecl(SILLocation loc, ConcreteDeclRef declRef, Type ncRefType,
863
863
}
864
864
CanType refType = ncRefType->getCanonicalType();
865
865
866
- auto getUnmanagedRValue = [&](SILValue value) -> RValue {
867
- return RValue(*this, loc, refType, ManagedValue::forUnmanaged(value));
868
- };
869
-
870
866
// If this is a reference to a module, produce an undef value. The
871
867
// module value should never actually be used.
872
868
if (isa<ModuleDecl>(decl)) {
873
- return getUnmanagedRValue(
874
- SILUndef::get(getLoweredLoadableType(ncRefType), SGM.M));
869
+ return emitUndefRValue(loc, refType);
875
870
}
876
871
877
872
// If this is a reference to a type, produce a metatype.
878
873
if (isa<TypeDecl>(decl)) {
879
874
assert(refType->is<MetatypeType>() &&
880
875
"type declref does not have metatype type?!");
881
- return getUnmanagedRValue(B.createMetatype(loc, getLoweredType(refType)));
876
+ return RValue(*this, loc, refType,
877
+ ManagedValue::forUnmanaged(
878
+ B.createMetatype(loc, getLoweredType(refType))));
882
879
}
883
880
884
881
// If this is a reference to a var, emit it as an l-value and then load.
@@ -1473,7 +1470,7 @@ static ManagedValue convertCFunctionSignature(SILGenFunction &SGF,
1473
1470
// just runs the risk of tripping up asserts in SILGenBridging.cpp
1474
1471
SGF.SGM.diagnose(e, diag::unsupported_c_function_pointer_conversion,
1475
1472
e->getSubExpr()->getType(), e->getType());
1476
- result = SGF.emitUndef(e, loweredDestTy);
1473
+ result = SGF.emitUndef(loweredDestTy);
1477
1474
break;
1478
1475
1479
1476
case TypeConverter::ABIDifference::ThinToThick:
@@ -1657,13 +1654,13 @@ RValue RValueEmitter::visitFunctionConversionExpr(FunctionConversionExpr *e,
1657
1654
} else {
1658
1655
SGF.SGM.diagnose(e->getLoc(), diag::not_implemented,
1659
1656
"nontrivial thin function reference");
1660
- value = ManagedValue::forUnmanaged(SILUndef::get(expectedTy, SGF.SGM.M) );
1657
+ value = SGF.emitUndef(expectedTy );
1661
1658
}
1662
1659
1663
1660
if (value.getType() != expectedTy) {
1664
1661
SGF.SGM.diagnose(e->getLoc(), diag::not_implemented,
1665
1662
"nontrivial thin function reference");
1666
- value = ManagedValue::forUnmanaged(SILUndef::get(expectedTy, SGF.SGM.M) );
1663
+ value = SGF.emitUndef(expectedTy );
1667
1664
}
1668
1665
return RValue(SGF, e, value);
1669
1666
}
@@ -2524,7 +2521,7 @@ RValue RValueEmitter::visitObjCSelectorExpr(ObjCSelectorExpr *e, SGFContext C) {
2524
2521
}
2525
2522
if (!selectorMemberTy) {
2526
2523
SGF.SGM.diagnose(e, diag::objc_selector_malformed);
2527
- return RValue(SGF, e, SGF.emitUndef(e, loweredSelectorTy));
2524
+ return RValue(SGF, e, SGF.emitUndef(loweredSelectorTy));
2528
2525
}
2529
2526
2530
2527
// Form the selector string.
@@ -5488,14 +5485,14 @@ ManagedValue SILGenFunction::emitRValueAsSingleValue(Expr *E, SGFContext C) {
5488
5485
5489
5486
RValue SILGenFunction::emitUndefRValue(SILLocation loc, Type type) {
5490
5487
return RValue(*this, loc, type->getCanonicalType(),
5491
- emitUndef(loc, getLoweredType(type)));
5488
+ emitUndef(getLoweredType(type)));
5492
5489
}
5493
5490
5494
- ManagedValue SILGenFunction::emitUndef(SILLocation loc, Type type) {
5495
- return emitUndef(loc, getLoweredType(type));
5491
+ ManagedValue SILGenFunction::emitUndef(Type type) {
5492
+ return emitUndef(getLoweredType(type));
5496
5493
}
5497
5494
5498
- ManagedValue SILGenFunction::emitUndef(SILLocation loc, SILType type) {
5499
- SILValue undef = SILUndef::get(type, SGM.M );
5495
+ ManagedValue SILGenFunction::emitUndef(SILType type) {
5496
+ SILValue undef = SILUndef::get(type, F );
5500
5497
return ManagedValue::forUnmanaged(undef);
5501
5498
}
0 commit comments