Skip to content

Commit b1a8d3b

Browse files
committed
Add a new parameter convention @in_cxx for non-trivial C++ classes
that are passed indirectly and destructed by the caller Fix a bug where `@in`, which indicates the callee is responsible for destroying the passed object, was being used to pass such classes. rdar://122707697
1 parent a16ad9c commit b1a8d3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+175
-8
lines changed

include/swift/AST/Types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,6 +4059,11 @@ enum class ParameterConvention : uint8_t {
40594059
/// convention used by mutable captures in @noescape closures.
40604060
Indirect_InoutAliasable,
40614061

4062+
/// This argument is passed indirectly, i.e. by directly passing the address
4063+
/// of an object in memory. The callee may modify, but does not destroy the
4064+
/// object.
4065+
Indirect_In_CXX,
4066+
40624067
/// This argument is passed directly. Its type is non-trivial, and the callee
40634068
/// is responsible for destroying it.
40644069
Direct_Owned,
@@ -4099,6 +4104,7 @@ inline bool isIndirectFormalParameter(ParameterConvention conv) {
40994104
case ParameterConvention::Indirect_In:
41004105
case ParameterConvention::Indirect_Inout:
41014106
case ParameterConvention::Indirect_InoutAliasable:
4107+
case ParameterConvention::Indirect_In_CXX:
41024108
case ParameterConvention::Indirect_In_Guaranteed:
41034109
return true;
41044110

@@ -4121,6 +4127,7 @@ inline bool isConsumedParameter(ParameterConvention conv) {
41214127

41224128
case ParameterConvention::Indirect_Inout:
41234129
case ParameterConvention::Indirect_InoutAliasable:
4130+
case ParameterConvention::Indirect_In_CXX:
41244131
case ParameterConvention::Direct_Unowned:
41254132
case ParameterConvention::Direct_Guaranteed:
41264133
case ParameterConvention::Indirect_In_Guaranteed:
@@ -4143,6 +4150,7 @@ inline bool isGuaranteedParameter(ParameterConvention conv) {
41434150

41444151
case ParameterConvention::Indirect_Inout:
41454152
case ParameterConvention::Indirect_InoutAliasable:
4153+
case ParameterConvention::Indirect_In_CXX:
41464154
case ParameterConvention::Indirect_In:
41474155
case ParameterConvention::Direct_Unowned:
41484156
case ParameterConvention::Direct_Owned:
@@ -4157,6 +4165,7 @@ inline bool isMutatingParameter(ParameterConvention conv) {
41574165
switch (conv) {
41584166
case ParameterConvention::Indirect_Inout:
41594167
case ParameterConvention::Indirect_InoutAliasable:
4168+
case ParameterConvention::Indirect_In_CXX:
41604169
case ParameterConvention::Pack_Inout:
41614170
return true;
41624171

@@ -4183,6 +4192,7 @@ inline bool isPackParameter(ParameterConvention conv) {
41834192
case ParameterConvention::Indirect_In_Guaranteed:
41844193
case ParameterConvention::Indirect_Inout:
41854194
case ParameterConvention::Indirect_InoutAliasable:
4195+
case ParameterConvention::Indirect_In_CXX:
41864196
case ParameterConvention::Indirect_In:
41874197
case ParameterConvention::Direct_Guaranteed:
41884198
case ParameterConvention::Direct_Unowned:

include/swift/SIL/ApplySite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ class ApplySite {
412412
: SILArgumentConvention::Direct_Owned;
413413
case SILArgumentConvention::Indirect_In:
414414
case SILArgumentConvention::Indirect_In_Guaranteed:
415+
case SILArgumentConvention::Indirect_In_CXX:
415416
return pai->isOnStack() ? SILArgumentConvention::Indirect_In_Guaranteed
416417
: SILArgumentConvention::Indirect_In;
417418
case SILArgumentConvention::Pack_Guaranteed:

include/swift/SIL/SILArgumentConvention.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct SILArgumentConvention {
2828
Indirect_In_Guaranteed,
2929
Indirect_Inout,
3030
Indirect_InoutAliasable,
31+
Indirect_In_CXX,
3132
Indirect_Out,
3233
Direct_Owned,
3334
Direct_Unowned,
@@ -55,6 +56,9 @@ struct SILArgumentConvention {
5556
case ParameterConvention::Indirect_In_Guaranteed:
5657
Value = SILArgumentConvention::Indirect_In_Guaranteed;
5758
return;
59+
case ParameterConvention::Indirect_In_CXX:
60+
Value = SILArgumentConvention::Indirect_In_CXX;
61+
return;
5862
case ParameterConvention::Direct_Unowned:
5963
Value = SILArgumentConvention::Direct_Unowned;
6064
return;
@@ -92,6 +96,7 @@ struct SILArgumentConvention {
9296
case SILArgumentConvention::Indirect_In_Guaranteed:
9397
case SILArgumentConvention::Indirect_In:
9498
case SILArgumentConvention::Indirect_Out:
99+
case SILArgumentConvention::Indirect_In_CXX:
95100
case SILArgumentConvention::Direct_Unowned:
96101
case SILArgumentConvention::Direct_Owned:
97102
case SILArgumentConvention::Direct_Guaranteed:
@@ -114,6 +119,7 @@ struct SILArgumentConvention {
114119
case SILArgumentConvention::Indirect_Inout:
115120
case SILArgumentConvention::Indirect_Out:
116121
case SILArgumentConvention::Indirect_InoutAliasable:
122+
case SILArgumentConvention::Indirect_In_CXX:
117123
case SILArgumentConvention::Direct_Unowned:
118124
case SILArgumentConvention::Pack_Inout:
119125
case SILArgumentConvention::Pack_Guaranteed:
@@ -133,6 +139,7 @@ struct SILArgumentConvention {
133139
case SILArgumentConvention::Indirect_In:
134140
case SILArgumentConvention::Indirect_Out:
135141
case SILArgumentConvention::Indirect_InoutAliasable:
142+
case SILArgumentConvention::Indirect_In_CXX:
136143
case SILArgumentConvention::Direct_Unowned:
137144
case SILArgumentConvention::Direct_Owned:
138145
case SILArgumentConvention::Pack_Inout:
@@ -150,6 +157,7 @@ struct SILArgumentConvention {
150157
case SILArgumentConvention::Indirect_Out:
151158
case SILArgumentConvention::Indirect_In_Guaranteed:
152159
case SILArgumentConvention::Indirect_Inout:
160+
case SILArgumentConvention::Indirect_In_CXX:
153161
return true;
154162

155163
case SILArgumentConvention::Indirect_InoutAliasable:
@@ -176,6 +184,7 @@ struct SILArgumentConvention {
176184
case SILArgumentConvention::Indirect_In_Guaranteed:
177185
case SILArgumentConvention::Indirect_Inout:
178186
case SILArgumentConvention::Indirect_InoutAliasable:
187+
case SILArgumentConvention::Indirect_In_CXX:
179188
case SILArgumentConvention::Direct_Unowned:
180189
case SILArgumentConvention::Direct_Guaranteed:
181190
case SILArgumentConvention::Direct_Owned:

include/swift/SIL/SILBridging.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ enum class BridgedArgumentConvention {
136136
Indirect_In_Guaranteed,
137137
Indirect_Inout,
138138
Indirect_InoutAliasable,
139+
Indirect_In_CXX,
139140
Indirect_Out,
140141
Direct_Owned,
141142
Direct_Unowned,
@@ -167,6 +168,7 @@ struct BridgedParameterInfo {
167168
case BridgedArgumentConvention::Indirect_In_Guaranteed: return swift::ParameterConvention::Indirect_In_Guaranteed;
168169
case BridgedArgumentConvention::Indirect_Inout: return swift::ParameterConvention::Indirect_Inout;
169170
case BridgedArgumentConvention::Indirect_InoutAliasable: return swift::ParameterConvention::Indirect_InoutAliasable;
171+
case BridgedArgumentConvention::Indirect_In_CXX: return swift::ParameterConvention::Indirect_In_CXX;
170172
case BridgedArgumentConvention::Indirect_Out: break;
171173
case BridgedArgumentConvention::Direct_Owned: return swift::ParameterConvention::Direct_Owned;
172174
case BridgedArgumentConvention::Direct_Unowned: return swift::ParameterConvention::Direct_Unowned;

include/swift/SIL/SILFunctionConventions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ inline bool SILModuleConventions::isIndirectSILParam(SILParameterInfo param,
592592

593593
case ParameterConvention::Indirect_In:
594594
case ParameterConvention::Indirect_In_Guaranteed:
595+
case ParameterConvention::Indirect_In_CXX:
595596
return isTypeIndirectForIndirectParamConvention(param.getInterfaceType(),
596597
loweredAddresses);
597598
case ParameterConvention::Indirect_Inout:

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ static char getParamConvention(ParameterConvention conv) {
11361136
case ParameterConvention::Indirect_Inout: return 'l';
11371137
case ParameterConvention::Indirect_InoutAliasable: return 'b';
11381138
case ParameterConvention::Indirect_In_Guaranteed: return 'n';
1139+
case ParameterConvention::Indirect_In_CXX: return 'C';
11391140
case ParameterConvention::Direct_Owned: return 'x';
11401141
case ParameterConvention::Direct_Unowned: return 'y';
11411142
case ParameterConvention::Direct_Guaranteed: return 'g';

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6721,6 +6721,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
67216721
case ParameterConvention::Indirect_In:
67226722
case ParameterConvention::Indirect_Inout:
67236723
case ParameterConvention::Indirect_InoutAliasable:
6724+
case ParameterConvention::Indirect_In_CXX:
67246725
case ParameterConvention::Indirect_In_Guaranteed:
67256726
llvm_unreachable("callee convention cannot be indirect");
67266727
case ParameterConvention::Pack_Guaranteed:
@@ -7490,6 +7491,7 @@ StringRef swift::getStringForParameterConvention(ParameterConvention conv) {
74907491
case ParameterConvention::Indirect_In_Guaranteed: return "@in_guaranteed ";
74917492
case ParameterConvention::Indirect_Inout: return "@inout ";
74927493
case ParameterConvention::Indirect_InoutAliasable: return "@inout_aliasable ";
7494+
case ParameterConvention::Indirect_In_CXX: return "@in_cxx ";
74937495
case ParameterConvention::Direct_Owned: return "@owned ";
74947496
case ParameterConvention::Direct_Unowned: return "";
74957497
case ParameterConvention::Direct_Guaranteed: return "@guaranteed ";

lib/IRGen/GenCall.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,7 @@ const TypeInfo &SignatureExpansion::expand(SILParameterInfo param) {
16381638
switch (auto conv = param.getConvention()) {
16391639
case ParameterConvention::Indirect_In:
16401640
case ParameterConvention::Indirect_In_Guaranteed:
1641+
case ParameterConvention::Indirect_In_CXX:
16411642
addIndirectValueParameterAttributes(IGM, Attrs, ti, ParamIRTypes.size());
16421643
addPointerParameter(IGM.getStorageType(getSILFuncConventions().getSILType(
16431644
param, IGM.getMaximalTypeExpansionContext())));

lib/IRGen/GenDistributed.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ void DistributedAccessor::decodeArgument(unsigned argumentIdx,
544544
break;
545545
}
546546

547+
case ParameterConvention::Indirect_In_CXX:
547548
case ParameterConvention::Indirect_In_Guaranteed: {
548549
// The argument is +0, so we can use the address of the param in
549550
// the context directly.

lib/IRGen/GenFunc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ CanType irgen::getArgumentLoweringType(CanType type, SILParameterInfo paramInfo,
846846
// address.
847847
case ParameterConvention::Indirect_In:
848848
case ParameterConvention::Indirect_In_Guaranteed:
849+
case ParameterConvention::Indirect_In_CXX:
849850
if (isNoEscape)
850851
return CanInOutType::get(type);
851852
else
@@ -1508,6 +1509,7 @@ static llvm::Value *emitPartialApplicationForwarder(
15081509
break;
15091510
case ParameterConvention::Indirect_Inout:
15101511
case ParameterConvention::Indirect_InoutAliasable:
1512+
case ParameterConvention::Indirect_In_CXX:
15111513
case ParameterConvention::Indirect_In:
15121514
case ParameterConvention::Indirect_In_Guaranteed:
15131515
case ParameterConvention::Pack_Guaranteed:
@@ -1625,6 +1627,7 @@ static llvm::Value *emitPartialApplicationForwarder(
16251627
break;
16261628

16271629
case ParameterConvention::Indirect_In_Guaranteed:
1630+
case ParameterConvention::Indirect_In_CXX:
16281631
case ParameterConvention::Direct_Guaranteed:
16291632
dependsOnContextLifetime = true;
16301633
if (outType->getCalleeConvention() ==
@@ -1750,6 +1753,7 @@ static llvm::Value *emitPartialApplicationForwarder(
17501753
}
17511754
break;
17521755
}
1756+
case ParameterConvention::Indirect_In_CXX:
17531757
case ParameterConvention::Indirect_In_Guaranteed:
17541758
if (outType->isNoEscape()) {
17551759
cast<LoadableTypeInfo>(fieldTI).loadAsCopy(subIGF, fieldAddr, param);
@@ -2301,6 +2305,7 @@ std::optional<StackAddress> irgen::emitFunctionPartialApplication(
23012305
switch (argConventions[i]) {
23022306
// Take indirect value arguments out of memory.
23032307
case ParameterConvention::Indirect_In:
2308+
case ParameterConvention::Indirect_In_CXX:
23042309
case ParameterConvention::Indirect_In_Guaranteed: {
23052310
if (outType->isNoEscape()) {
23062311
cast<LoadableTypeInfo>(fieldLayout.getType())

lib/IRGen/GenObjC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
948948
case ParameterConvention::Indirect_In:
949949
case ParameterConvention::Indirect_Inout:
950950
case ParameterConvention::Indirect_InoutAliasable:
951+
case ParameterConvention::Indirect_In_CXX:
951952
case ParameterConvention::Pack_Guaranteed:
952953
case ParameterConvention::Pack_Owned:
953954
case ParameterConvention::Pack_Inout:

lib/IRGen/GenProto.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
393393
case ParameterConvention::Indirect_In_Guaranteed:
394394
case ParameterConvention::Indirect_Inout:
395395
case ParameterConvention::Indirect_InoutAliasable:
396+
case ParameterConvention::Indirect_In_CXX:
396397
if (!isSelfParameter) return;
397398
if (type->getNominalOrBoundGenericNominal()) {
398399
considerNewTypeSource(IsExact,

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ static OperandOwnership getFunctionArgOwnership(SILArgumentConvention argConv,
505505
case SILArgumentConvention::Direct_Unowned:
506506
return OperandOwnership::UnownedInstantaneousUse;
507507

508+
case SILArgumentConvention::Indirect_In_CXX:
509+
return OperandOwnership::InstantaneousUse;
510+
508511
case SILArgumentConvention::Indirect_Out:
509512
case SILArgumentConvention::Indirect_Inout:
510513
case SILArgumentConvention::Indirect_InoutAliasable:

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ static CanSILFunctionType getAutoDiffPullbackType(
713713
case ParameterConvention::Indirect_Inout:
714714
case ParameterConvention::Indirect_In_Guaranteed:
715715
case ParameterConvention::Indirect_InoutAliasable:
716+
case ParameterConvention::Indirect_In_CXX:
716717
conv = ResultConvention::Indirect;
717718
break;
718719
}
@@ -1050,6 +1051,7 @@ CanSILFunctionType SILFunctionType::getAutoDiffTransposeFunctionType(
10501051
case ParameterConvention::Indirect_Inout:
10511052
case ParameterConvention::Indirect_In_Guaranteed:
10521053
case ParameterConvention::Indirect_InoutAliasable:
1054+
case ParameterConvention::Indirect_In_CXX:
10531055
newConv = ResultConvention::Indirect;
10541056
break;
10551057
}
@@ -3335,6 +3337,9 @@ static ParameterConvention getIndirectCParameterConvention(clang::QualType type)
33353337
// A trivial const * parameter in C should be considered @in.
33363338
if (importer::isCxxConstReferenceType(type.getTypePtr()))
33373339
return ParameterConvention::Indirect_In_Guaranteed;
3340+
if (auto *decl = type->getAsRecordDecl())
3341+
if (!decl->isParamDestroyedInCallee())
3342+
return ParameterConvention::Indirect_In_CXX;
33383343
return ParameterConvention::Indirect_In;
33393344
}
33403345

lib/SIL/IR/SILPrinter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
15891589
case ParameterConvention::Indirect_Inout:
15901590
case ParameterConvention::Indirect_In_Guaranteed:
15911591
case ParameterConvention::Indirect_InoutAliasable:
1592+
case ParameterConvention::Indirect_In_CXX:
15921593
case ParameterConvention::Pack_Guaranteed:
15931594
case ParameterConvention::Pack_Owned:
15941595
case ParameterConvention::Pack_Inout:

lib/SIL/IR/SILValue.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ ValueOwnershipKind::ValueOwnershipKind(const SILFunction &F, SILType Type,
313313
break;
314314
case SILArgumentConvention::Indirect_Inout:
315315
case SILArgumentConvention::Indirect_InoutAliasable:
316+
case SILArgumentConvention::Indirect_In_CXX:
316317
case SILArgumentConvention::Indirect_Out:
317318
case SILArgumentConvention::Pack_Inout:
318319
case SILArgumentConvention::Pack_Out:

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,7 @@ bool GatherUniqueStorageUses::visitUse(Operand *use, AccessUseType useTy) {
21932193
case SILArgumentConvention::Indirect_Inout:
21942194
case SILArgumentConvention::Indirect_InoutAliasable:
21952195
case SILArgumentConvention::Indirect_Out:
2196+
case SILArgumentConvention::Indirect_In_CXX:
21962197
case SILArgumentConvention::Pack_Inout:
21972198
case SILArgumentConvention::Pack_Out:
21982199
return visitApplyOperand(use, visitor,

lib/SIL/Verifier/MemoryLifetimeVerifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ void MemoryLifetimeVerifier::setFuncOperandBits(BlockState &state, Operand &op,
578578
case SILArgumentConvention::Indirect_In_Guaranteed:
579579
case SILArgumentConvention::Indirect_Inout:
580580
case SILArgumentConvention::Indirect_InoutAliasable:
581+
case SILArgumentConvention::Indirect_In_CXX:
581582
case SILArgumentConvention::Direct_Owned:
582583
case SILArgumentConvention::Direct_Unowned:
583584
case SILArgumentConvention::Direct_Guaranteed:
@@ -901,6 +902,7 @@ void MemoryLifetimeVerifier::checkFuncArgument(Bits &bits, Operand &argumentOp,
901902
locations.setBits(bits, argumentOp.get());
902903
break;
903904
case SILArgumentConvention::Indirect_In_Guaranteed:
905+
case SILArgumentConvention::Indirect_In_CXX:
904906
case SILArgumentConvention::Indirect_Inout:
905907
requireBitsSetForArgument(bits, &argumentOp);
906908
break;

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ struct ImmutableAddressUseVerifier {
511511
case SILArgumentConvention::Indirect_Out:
512512
case SILArgumentConvention::Indirect_In:
513513
case SILArgumentConvention::Indirect_Inout:
514+
case SILArgumentConvention::Indirect_In_CXX:
514515
return true;
515516

516517
case SILArgumentConvention::Direct_Unowned:
@@ -6381,6 +6382,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
63816382
case ParameterConvention::Indirect_Inout:
63826383
case ParameterConvention::Indirect_InoutAliasable:
63836384
case ParameterConvention::Indirect_In_Guaranteed:
6385+
case ParameterConvention::Indirect_In_CXX:
63846386
case ParameterConvention::Pack_Owned:
63856387
case ParameterConvention::Pack_Guaranteed:
63866388
case ParameterConvention::Pack_Inout:

lib/SILGen/SILGenApply.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4358,7 +4358,7 @@ class ArgEmitter {
43584358
bool requiresReabstraction = loweredArgType.getASTType()
43594359
!= param.getInterfaceType();
43604360
// If the parameter is consumed, we have to emit at +1.
4361-
if (param.isConsumed()) {
4361+
if (param.isConsumed() || param.getConvention() == ParameterConvention::Indirect_In_CXX) {
43624362
return {SGFContext(), requiresReabstraction};
43634363
}
43644364

@@ -5598,6 +5598,7 @@ RValue SILGenFunction::emitApply(
55985598
case ParameterConvention::Indirect_In:
55995599
case ParameterConvention::Indirect_Inout:
56005600
case ParameterConvention::Indirect_InoutAliasable:
5601+
case ParameterConvention::Indirect_In_CXX:
56015602
case ParameterConvention::Pack_Guaranteed:
56025603
case ParameterConvention::Pack_Owned:
56035604
case ParameterConvention::Pack_Inout:
@@ -6848,6 +6849,7 @@ bool AccessorBaseArgPreparer::shouldLoadBaseAddress() const {
68486849
// memory to 'in', and we have pass at +1.
68496850
case ParameterConvention::Indirect_In:
68506851
case ParameterConvention::Indirect_In_Guaranteed:
6852+
case ParameterConvention::Indirect_In_CXX:
68516853
// TODO: We shouldn't be able to get an lvalue here, but the AST
68526854
// sometimes produces an inout base for non-mutating accessors.
68536855
// rdar://problem/19782170

lib/SILGen/SILGenBridging.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ static ManagedValue emitManagedParameter(SILGenFunction &SGF, SILLocation loc,
317317
case ParameterConvention::Indirect_Inout:
318318
return ManagedValue::forLValue(value);
319319

320+
case ParameterConvention::Indirect_In_CXX:
321+
return ManagedValue::forLValue(value);
322+
320323
case ParameterConvention::Indirect_In_Guaranteed:
321324
if (valueTL.isLoadable()) {
322325
return SGF.B.createLoadBorrow(
@@ -438,6 +441,7 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
438441
case ParameterConvention::Indirect_In_Guaranteed:
439442
case ParameterConvention::Indirect_Inout:
440443
case ParameterConvention::Indirect_InoutAliasable:
444+
case ParameterConvention::Indirect_In_CXX:
441445
case ParameterConvention::Pack_Guaranteed:
442446
case ParameterConvention::Pack_Owned:
443447
case ParameterConvention::Pack_Inout:
@@ -2175,6 +2179,7 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
21752179
case ParameterConvention::Indirect_In:
21762180
param = emitManagedRValueWithCleanup(paramValue);
21772181
break;
2182+
case ParameterConvention::Indirect_In_CXX:
21782183
case ParameterConvention::Indirect_In_Guaranteed: {
21792184
auto tmp = emitTemporaryAllocation(fd, paramValue->getType());
21802185
B.createCopyAddr(fd, paramValue, tmp, IsNotTake, IsInitialization);

lib/SILGen/SILGenBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ static ManagedValue createInputFunctionArgument(
573573

574574
case SILArgumentConvention::Indirect_Inout:
575575
case SILArgumentConvention::Indirect_InoutAliasable:
576+
case SILArgumentConvention::Indirect_In_CXX:
576577
case SILArgumentConvention::Pack_Inout:
577578
// An inout parameter is +0 and guaranteed, but represents an lvalue.
578579
return ManagedValue::forLValue(arg);

0 commit comments

Comments
 (0)