Skip to content

Commit 198b974

Browse files
authored
Merge pull request #59859 from gottesmm/pr-276c4e4220a25490659a285e8b94a36bd28ffede
[no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
2 parents afd65fa + 8f3fe63 commit 198b974

27 files changed

+84
-75
lines changed

include/swift/AST/TypeDifferenceVisitor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ class CanTypeDifferenceVisitor : public CanTypePairVisitor<Impl, bool> {
333333
return asImpl().visit(type1->getCaptureType(), type2->getCaptureType());
334334
}
335335

336-
bool visitSILMoveOnlyType(CanSILMoveOnlyType type1,
337-
CanSILMoveOnlyType type2) {
336+
bool visitSILMoveOnlyWrappedType(CanSILMoveOnlyWrappedType type1,
337+
CanSILMoveOnlyWrappedType type2) {
338338
return asImpl().visit(type1->getInnerType(), type2->getInnerType());
339339
}
340340

include/swift/AST/TypeMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class TypeMatcher {
352352
TRIVIAL_CASE(SILFunctionType)
353353
TRIVIAL_CASE(SILBlockStorageType)
354354
TRIVIAL_CASE(SILBoxType)
355-
TRIVIAL_CASE(SILMoveOnlyType)
355+
TRIVIAL_CASE(SILMoveOnlyWrappedType)
356356

357357
bool visitProtocolCompositionType(CanProtocolCompositionType firstProtocolComposition,
358358
Type secondType,

include/swift/AST/TypeNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ ABSTRACT_TYPE(AnyFunction, Type)
159159
ARTIFICIAL_TYPE(SILFunction, Type)
160160
ARTIFICIAL_TYPE(SILBlockStorage, Type)
161161
ARTIFICIAL_TYPE(SILBox, Type)
162-
ARTIFICIAL_TYPE(SILMoveOnly, Type)
162+
ARTIFICIAL_TYPE(SILMoveOnlyWrapped, Type)
163163
ARTIFICIAL_TYPE(SILToken, Type)
164164
TYPE(ProtocolComposition, Type)
165165
TYPE(ParameterizedProtocol, Type)

include/swift/AST/Types.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5002,19 +5002,20 @@ class SILBoxType final : public TypeBase, public llvm::FoldingSetNode
50025002
};
50035003
DEFINE_EMPTY_CAN_TYPE_WRAPPER(SILBoxType, Type)
50045004

5005-
class SILMoveOnlyType;
5005+
class SILMoveOnlyWrappedType;
50065006
class SILModule; // From SIL
5007-
typedef CanTypeWrapper<SILMoveOnlyType> CanMoveOnlyType;
5007+
typedef CanTypeWrapper<SILMoveOnlyWrappedType> CanMoveOnlyType;
50085008

50095009
/// A wrapper type that marks an inner type as being a move only value. Can not
50105010
/// be written directly at the Swift level, instead it is triggered by adding
50115011
/// the type attribute @_moveOnly to a different type. We transform these in
50125012
/// TypeLowering into a moveOnly SILType on the inner type.
5013-
class SILMoveOnlyType final : public TypeBase, public llvm::FoldingSetNode {
5013+
class SILMoveOnlyWrappedType final : public TypeBase,
5014+
public llvm::FoldingSetNode {
50145015
CanType innerType;
50155016

5016-
SILMoveOnlyType(CanType innerType)
5017-
: TypeBase(TypeKind::SILMoveOnly, &innerType->getASTContext(),
5017+
SILMoveOnlyWrappedType(CanType innerType)
5018+
: TypeBase(TypeKind::SILMoveOnlyWrapped, &innerType->getASTContext(),
50185019
innerType->getRecursiveProperties()),
50195020
innerType(innerType) {}
50205021

@@ -5024,10 +5025,10 @@ class SILMoveOnlyType final : public TypeBase, public llvm::FoldingSetNode {
50245025
static CanMoveOnlyType get(CanType innerType);
50255026

50265027
static bool classof(const TypeBase *T) {
5027-
return T->getKind() == TypeKind::SILMoveOnly;
5028+
return T->getKind() == TypeKind::SILMoveOnlyWrapped;
50285029
}
50295030
};
5030-
DEFINE_EMPTY_CAN_TYPE_WRAPPER(SILMoveOnlyType, Type)
5031+
DEFINE_EMPTY_CAN_TYPE_WRAPPER(SILMoveOnlyWrappedType, Type)
50315032

50325033
class SILBlockStorageType;
50335034
typedef CanTypeWrapper<SILBlockStorageType> CanSILBlockStorageType;

include/swift/SIL/SILType.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ class SILType {
607607
/// Canonical way to check if a SILType is move only. Using is/getAs/castTo
608608
/// will look through moveonly-ness.
609609
bool isMoveOnlyWrapped() const {
610-
return getRawASTType()->is<SILMoveOnlyType>();
610+
return getRawASTType()->is<SILMoveOnlyWrappedType>();
611611
}
612612

613613
/// If this is already a move only wrapped type, return *this. Otherwise, wrap
614614
/// the copyable type in the mov eonly wrapper.
615615
SILType addingMoveOnlyWrapper() const {
616616
if (isMoveOnlyWrapped())
617617
return *this;
618-
auto newType = SILMoveOnlyType::get(getRawASTType());
618+
auto newType = SILMoveOnlyWrappedType::get(getRawASTType());
619619
return SILType::getPrimitiveType(newType, getCategory());
620620
}
621621

@@ -624,7 +624,7 @@ class SILType {
624624
SILType removingMoveOnlyWrapper() const {
625625
if (!isMoveOnlyWrapped())
626626
return *this;
627-
auto moveOnly = getRawASTType()->castTo<SILMoveOnlyType>();
627+
auto moveOnly = getRawASTType()->castTo<SILMoveOnlyWrappedType>();
628628
return SILType::getPrimitiveType(moveOnly->getInnerType(), getCategory());
629629
}
630630

include/swift/SIL/SILValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
563563
/// otherwise.
564564
///
565565
/// NOTE: Please do not use this directly! It is only meant to be used by the
566-
/// optimizer pass: SILMoveOnlyTypeEliminator.
566+
/// optimizer pass: SILMoveOnlyWrappedTypeEliminator.
567567
bool unsafelyEliminateMoveOnlyWrapper() {
568568
if (!Type.isMoveOnlyWrapped())
569569
return false;

lib/AST/ASTContext.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ struct ASTContext::Implementation {
462462
llvm::FoldingSet<GenericFunctionType> GenericFunctionTypes;
463463
llvm::FoldingSet<SILFunctionType> SILFunctionTypes;
464464
llvm::DenseMap<CanType, SILBlockStorageType *> SILBlockStorageTypes;
465-
llvm::DenseMap<CanType, SILMoveOnlyType *> SILMoveOnlyTypes;
465+
llvm::DenseMap<CanType, SILMoveOnlyWrappedType *> SILMoveOnlyWrappedTypes;
466466
llvm::FoldingSet<SILBoxType> SILBoxTypes;
467467
llvm::DenseMap<BuiltinIntegerWidth, BuiltinIntegerType*> IntegerTypes;
468468
llvm::FoldingSet<BuiltinVectorType> BuiltinVectorTypes;
@@ -4078,17 +4078,18 @@ SILFunctionType::SILFunctionType(
40784078
#endif
40794079
}
40804080

4081-
CanSILMoveOnlyType SILMoveOnlyType::get(CanType innerType) {
4081+
CanSILMoveOnlyWrappedType SILMoveOnlyWrappedType::get(CanType innerType) {
40824082
ASTContext &ctx = innerType->getASTContext();
4083-
auto found = ctx.getImpl().SILMoveOnlyTypes.find(innerType);
4084-
if (found != ctx.getImpl().SILMoveOnlyTypes.end())
4085-
return CanSILMoveOnlyType(found->second);
4083+
auto found = ctx.getImpl().SILMoveOnlyWrappedTypes.find(innerType);
4084+
if (found != ctx.getImpl().SILMoveOnlyWrappedTypes.end())
4085+
return CanSILMoveOnlyWrappedType(found->second);
40864086

4087-
void *mem = ctx.Allocate(sizeof(SILMoveOnlyType), alignof(SILMoveOnlyType));
4087+
void *mem = ctx.Allocate(sizeof(SILMoveOnlyWrappedType),
4088+
alignof(SILMoveOnlyWrappedType));
40884089

4089-
auto *storageTy = new (mem) SILMoveOnlyType(innerType);
4090-
ctx.getImpl().SILMoveOnlyTypes.insert({innerType, storageTy});
4091-
return CanSILMoveOnlyType(storageTy);
4090+
auto *storageTy = new (mem) SILMoveOnlyWrappedType(innerType);
4091+
ctx.getImpl().SILMoveOnlyWrappedTypes.insert({innerType, storageTy});
4092+
return CanSILMoveOnlyWrappedType(storageTy);
40924093
}
40934094

40944095
CanSILBlockStorageType SILBlockStorageType::get(CanType captureType) {

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3941,7 +3941,8 @@ namespace {
39413941
PrintWithColorRAII(OS, ParenthesisColor) << ')';
39423942
}
39433943

3944-
void visitSILMoveOnlyType(SILMoveOnlyType *T, StringRef label) {
3944+
void visitSILMoveOnlyWrappedType(SILMoveOnlyWrappedType *T,
3945+
StringRef label) {
39453946
printCommon(label, "sil_move_only_type");
39463947
printRec(T->getInnerType());
39473948
PrintWithColorRAII(OS, ParenthesisColor) << ')';

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
14731473

14741474
return;
14751475
}
1476-
case TypeKind::SILMoveOnly:
1476+
case TypeKind::SILMoveOnlyWrapped:
14771477
// If we hit this, we just mangle the underlying name and move on.
14781478
llvm_unreachable("should never be mangled?");
14791479
case TypeKind::SILBlockStorage:

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6203,7 +6203,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
62036203
}
62046204
}
62056205

6206-
void visitSILMoveOnlyType(SILMoveOnlyType *T) {
6206+
void visitSILMoveOnlyWrappedType(SILMoveOnlyWrappedType *T) {
62076207
Printer << "@moveOnly ";
62086208
printWithParensIfNotSimple(T->getInnerType());
62096209
}

lib/AST/ExistentialGeneralization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class Generalizer : public CanTypeVisitor<Generalizer, Type> {
175175
INVALID_TO_GENERALIZE(SILBox)
176176
INVALID_TO_GENERALIZE(SILFunction)
177177
INVALID_TO_GENERALIZE(SILToken)
178-
INVALID_TO_GENERALIZE(SILMoveOnly)
178+
INVALID_TO_GENERALIZE(SILMoveOnlyWrapped)
179179
#undef INVALID_TO_GENERALIZE
180180

181181
/// Generalize the generic arguments of the given generic type.s

lib/AST/Type.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ bool CanType::isReferenceTypeImpl(CanType type, const GenericSignatureImpl *sig,
192192
case TypeKind::DynamicSelf:
193193
return isReferenceTypeImpl(cast<DynamicSelfType>(type).getSelfType(),
194194
sig, functionsCount);
195-
case TypeKind::SILMoveOnly:
196-
return isReferenceTypeImpl(cast<SILMoveOnlyType>(type)->getInnerType(), sig,
197-
functionsCount);
195+
case TypeKind::SILMoveOnlyWrapped:
196+
return isReferenceTypeImpl(
197+
cast<SILMoveOnlyWrappedType>(type)->getInnerType(), sig,
198+
functionsCount);
198199

199200
// Archetypes and existentials are only class references if class-bounded.
200201
case TypeKind::PrimaryArchetype:
@@ -330,7 +331,7 @@ ExistentialLayout CanType::getExistentialLayout() {
330331
CanType ty = *this;
331332

332333
// Always remove one layer of move only ness.
333-
if (auto mv = dyn_cast<SILMoveOnlyType>(ty))
334+
if (auto mv = dyn_cast<SILMoveOnlyWrappedType>(ty))
334335
ty = mv->getInnerType();
335336

336337
if (auto existential = dyn_cast<ExistentialType>(ty))
@@ -1685,7 +1686,7 @@ CanType TypeBase::computeCanonicalType() {
16851686
case TypeKind::SILBox:
16861687
case TypeKind::SILFunction:
16871688
case TypeKind::SILToken:
1688-
case TypeKind::SILMoveOnly:
1689+
case TypeKind::SILMoveOnlyWrapped:
16891690
llvm_unreachable("SIL-only types are always canonical!");
16901691

16911692
case TypeKind::ProtocolComposition: {
@@ -5149,15 +5150,15 @@ case TypeKind::Id:
51495150
return storageTy;
51505151
}
51515152

5152-
case TypeKind::SILMoveOnly: {
5153-
auto *storageTy = cast<SILMoveOnlyType>(base);
5153+
case TypeKind::SILMoveOnlyWrapped: {
5154+
auto *storageTy = cast<SILMoveOnlyWrappedType>(base);
51545155
Type transCap = storageTy->getInnerType().transformWithPosition(
51555156
TypePosition::Invariant, fn);
51565157
if (!transCap)
51575158
return Type();
51585159
CanType canTransCap = transCap->getCanonicalType();
51595160
if (canTransCap != storageTy->getInnerType())
5160-
return SILMoveOnlyType::get(canTransCap);
5161+
return SILMoveOnlyWrappedType::get(canTransCap);
51615162
return storageTy;
51625163
}
51635164

@@ -6071,8 +6072,10 @@ ReferenceCounting TypeBase::getReferenceCounting() {
60716072
case TypeKind::DynamicSelf:
60726073
return cast<DynamicSelfType>(type).getSelfType()
60736074
->getReferenceCounting();
6074-
case TypeKind::SILMoveOnly:
6075-
return cast<SILMoveOnlyType>(type)->getInnerType()->getReferenceCounting();
6075+
case TypeKind::SILMoveOnlyWrapped:
6076+
return cast<SILMoveOnlyWrappedType>(type)
6077+
->getInnerType()
6078+
->getReferenceCounting();
60766079

60776080
case TypeKind::PrimaryArchetype:
60786081
case TypeKind::OpenedArchetype:

lib/AST/TypeWalker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class Traversal : public TypeVisitor<Traversal, bool>
234234
return doIt(ty->getCaptureType());
235235
}
236236

237-
bool visitSILMoveOnlyType(SILMoveOnlyType *ty) {
237+
bool visitSILMoveOnlyWrappedType(SILMoveOnlyWrappedType *ty) {
238238
return doIt(ty->getInnerType());
239239
}
240240

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ class GetSendableType :
19201920
NEVER_VISIT(SILBlockStorageType)
19211921
NEVER_VISIT(SILBoxType)
19221922
NEVER_VISIT(SILTokenType)
1923-
NEVER_VISIT(SILMoveOnlyType)
1923+
NEVER_VISIT(SILMoveOnlyWrappedType)
19241924

19251925
VISIT(ProtocolCompositionType, compose)
19261926

lib/IRGen/GenType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ const TypeInfo *TypeConverter::convertType(CanType ty) {
21692169
case TypeKind::BoundGenericEnum:
21702170
case TypeKind::BoundGenericStruct:
21712171
return convertAnyNominalType(ty, cast<BoundGenericType>(ty)->getDecl());
2172-
case TypeKind::SILMoveOnly:
2172+
case TypeKind::SILMoveOnlyWrapped:
21732173
llvm_unreachable("implement this");
21742174
case TypeKind::InOut:
21752175
return convertInOutType(cast<InOutType>(ty));

lib/IRGen/GenType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class TypeConverter {
158158
const TypeInfo *convertBoxType(SILBoxType *T);
159159
const TypeInfo *convertArchetypeType(ArchetypeType *T);
160160
const TypeInfo *convertInOutType(InOutType *T);
161-
const TypeInfo *convertSILMoveOnlyType(SILMoveOnlyType *T) {
161+
const TypeInfo *convertSILMoveOnlyWrappedType(SILMoveOnlyWrappedType *T) {
162162
return convertType(T->getInnerType());
163163
}
164164
const TypeInfo *convertExistentialMetatypeType(ExistentialMetatypeType *T);

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
17251725
case TypeKind::SILToken:
17261726
case TypeKind::BuiltinUnsafeValueBuffer:
17271727
case TypeKind::BuiltinDefaultActorStorage:
1728-
case TypeKind::SILMoveOnly:
1729-
1728+
case TypeKind::SILMoveOnlyWrapped:
17301729
LLVM_DEBUG(llvm::dbgs() << "Unhandled type: ";
17311730
DbgTy.getType()->dump(llvm::dbgs()); llvm::dbgs() << "\n");
17321731
MangledName = "<unknown>";

lib/IRGen/MetadataRequest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,9 @@ namespace {
19571957
DynamicMetadataRequest request) {
19581958
llvm_unreachable("should not be asking for metadata of a SILToken type");
19591959
}
1960-
MetadataResponse visitSILMoveOnlyType(CanSILMoveOnlyType type,
1961-
DynamicMetadataRequest request) {
1960+
MetadataResponse
1961+
visitSILMoveOnlyWrappedType(CanSILMoveOnlyWrappedType type,
1962+
DynamicMetadataRequest request) {
19621963
llvm_unreachable("should not be asking for metadata of a move only type");
19631964
}
19641965
MetadataResponse visitArchetypeType(CanArchetypeType type,

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ AbstractionPattern AbstractionPattern::removingMoveOnlyWrapper() const {
426426
case Kind::Opaque:
427427
case Kind::Tuple:
428428
case Kind::Type:
429-
if (auto mvi = dyn_cast<SILMoveOnlyType>(getType())) {
429+
if (auto mvi = dyn_cast<SILMoveOnlyWrappedType>(getType())) {
430430
return AbstractionPattern(getGenericSignature(), mvi->getInnerType());
431431
}
432432
return *this;
@@ -460,10 +460,10 @@ AbstractionPattern AbstractionPattern::addingMoveOnlyWrapper() const {
460460
case Kind::Opaque:
461461
case Kind::Tuple:
462462
case Kind::Type:
463-
if (isa<SILMoveOnlyType>(getType()))
463+
if (isa<SILMoveOnlyWrappedType>(getType()))
464464
return *this;
465465
return AbstractionPattern(getGenericSignature(),
466-
SILMoveOnlyType::get(getType()));
466+
SILMoveOnlyWrappedType::get(getType()));
467467
}
468468

469469
llvm_unreachable("bad kind");

lib/SIL/IR/SILType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ SILType SILType::getFieldType(VarDecl *field, TypeConverter &TC,
295295
// If this type is not a class type, then we propagate "move only"-ness to the
296296
// field. Example:
297297
if (!getClassOrBoundGenericClass() && isMoveOnlyWrapped())
298-
loweredTy = SILMoveOnlyType::get(loweredTy);
298+
loweredTy = SILMoveOnlyWrappedType::get(loweredTy);
299299

300300
if (isAddress() || getClassOrBoundGenericClass() != nullptr) {
301301
return SILType::getPrimitiveAddressType(loweredTy);

lib/SIL/IR/TypeLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,9 @@ namespace {
682682
type, getReferenceRecursiveProperties(isSensitive));
683683
}
684684

685-
RetTy visitSILMoveOnlyType(CanSILMoveOnlyType type,
686-
AbstractionPattern origType,
687-
IsTypeExpansionSensitive_t isSensitive) {
685+
RetTy visitSILMoveOnlyWrappedType(CanSILMoveOnlyWrappedType type,
686+
AbstractionPattern origType,
687+
IsTypeExpansionSensitive_t isSensitive) {
688688
AbstractionPattern innerAbstraction = origType.removingMoveOnlyWrapper();
689689
CanType innerType = type->getInnerType();
690690
auto &lowering =

lib/SILGen/SILGenDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class LetValueInitialization : public Initialization {
447447
if (SGF.getASTContext().LangOpts.Features.count(Feature::MoveOnly) &&
448448
vd->getAttrs().hasAttribute<NoImplicitCopyAttr>()) {
449449
lowering = &SGF.getTypeLowering(
450-
SILMoveOnlyType::get(vd->getType()->getCanonicalType()));
450+
SILMoveOnlyWrappedType::get(vd->getType()->getCanonicalType()));
451451
} else {
452452
lowering = &SGF.getTypeLowering(vd->getType());
453453
}
@@ -576,8 +576,9 @@ class LetValueInitialization : public Initialization {
576576
value->getOwnershipKind() == OwnershipKind::Owned) {
577577
assert(wasPlusOne);
578578
// NOTE: If our type is trivial when not wrapped in a
579-
// SILMoveOnlyType, this will return a trivial value. We rely on the
580-
// checker to determine if this is an acceptable use of the value.
579+
// SILMoveOnlyWrappedType, this will return a trivial value. We rely
580+
// on the checker to determine if this is an acceptable use of the
581+
// value.
581582
value = SGF.B.createOwnedMoveOnlyWrapperToCopyableValue(PrologueLoc,
582583
value);
583584
}

0 commit comments

Comments
 (0)