Skip to content

Commit 6e4e478

Browse files
committed
[NFC] [cxx-interop] Rename IsCxxNotTriviallyCopyable -> IsCxxNonTrivial.
`IsCxxNonTrivial` is set for a variety or reasons, for example, it's set when the struct contains bitfields, has a custom destructor, or a custom copy constructor. The name `IsCxxNotTriviallyCopyable` only implies the latter.
1 parent 059344d commit 6e4e478

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

include/swift/AST/Decl.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,14 @@ class alignas(1 << DeclAlignInBits) Decl {
554554
IsIncompatibleWithWeakReferences : 1
555555
);
556556

557-
SWIFT_INLINE_BITFIELD(StructDecl, NominalTypeDecl, 1+1,
558-
/// True if this struct has storage for fields that aren't accessible in
559-
/// Swift.
560-
HasUnreferenceableStorage : 1,
561-
/// True if this struct is imported from C++ and not trivially copyable.
562-
IsCxxNotTriviallyCopyable : 1
563-
);
564-
557+
SWIFT_INLINE_BITFIELD(
558+
StructDecl, NominalTypeDecl, 1 + 1,
559+
/// True if this struct has storage for fields that aren't accessible in
560+
/// Swift.
561+
HasUnreferenceableStorage : 1,
562+
/// True if this struct is imported from C++ and does not have trivial value witness functions.
563+
IsCxxNonTrivial : 1);
564+
565565
SWIFT_INLINE_BITFIELD(EnumDecl, NominalTypeDecl, 2+1,
566566
/// True if the enum has cases and at least one case has associated values.
567567
HasAssociatedValues : 2,
@@ -3789,13 +3789,9 @@ class StructDecl final : public NominalTypeDecl {
37893789
Bits.StructDecl.HasUnreferenceableStorage = v;
37903790
}
37913791

3792-
bool isCxxNotTriviallyCopyable() const {
3793-
return Bits.StructDecl.IsCxxNotTriviallyCopyable;
3794-
}
3792+
bool isCxxNonTrivial() const { return Bits.StructDecl.IsCxxNonTrivial; }
37953793

3796-
void setIsCxxNotTriviallyCopyable(bool v) {
3797-
Bits.StructDecl.IsCxxNotTriviallyCopyable = v;
3798-
}
3794+
void setIsCxxNonTrivial(bool v) { Bits.StructDecl.IsCxxNonTrivial = v; }
37993795
};
38003796

38013797
/// This is the base type for AncestryOptions. Each flag describes possible

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4132,7 +4132,7 @@ StructDecl::StructDecl(SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc,
41324132
StructLoc(StructLoc)
41334133
{
41344134
Bits.StructDecl.HasUnreferenceableStorage = false;
4135-
Bits.StructDecl.IsCxxNotTriviallyCopyable = false;
4135+
Bits.StructDecl.IsCxxNonTrivial = false;
41364136
}
41374137

41384138
bool NominalTypeDecl::hasMemberwiseInitializer() const {

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,20 +3454,19 @@ namespace {
34543454
result->setHasUnreferenceableStorage(hasUnreferenceableStorage);
34553455

34563456
if (auto cxxRecordDecl = dyn_cast<clang::CXXRecordDecl>(decl)) {
3457-
result->setIsCxxNotTriviallyCopyable(
3458-
!cxxRecordDecl->isTriviallyCopyable());
3457+
result->setIsCxxNonTrivial(!cxxRecordDecl->isTriviallyCopyable());
34593458

34603459
for (auto ctor : cxxRecordDecl->ctors()) {
34613460
if (ctor->isCopyConstructor() &&
34623461
(ctor->isDeleted() || ctor->getAccess() != clang::AS_public)) {
3463-
result->setIsCxxNotTriviallyCopyable(true);
3462+
result->setIsCxxNonTrivial(true);
34643463
break;
34653464
}
34663465
}
34673466

34683467
if (auto dtor = cxxRecordDecl->getDestructor()) {
34693468
if (dtor->isDeleted() || dtor->getAccess() != clang::AS_public) {
3470-
result->setIsCxxNotTriviallyCopyable(true);
3469+
result->setIsCxxNonTrivial(true);
34713470
}
34723471
}
34733472
}

lib/SIL/IR/TypeLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ namespace {
14521452
if (handleResilience(structType, D, properties))
14531453
return handleAddressOnly(structType, properties);
14541454

1455-
if (D->isCxxNotTriviallyCopyable()) {
1455+
if (D->isCxxNonTrivial()) {
14561456
properties.setAddressOnly();
14571457
properties.setNonTrivial();
14581458
}

0 commit comments

Comments
 (0)