Skip to content

Commit 0ca8d28

Browse files
committed
---
yaml --- r: 343507 b: refs/heads/master-rebranch c: c87e1a2 h: refs/heads/master i: 343505: 609e7e2 343503: 4ba4030
1 parent adcf0f5 commit 0ca8d28

File tree

7 files changed

+34
-9
lines changed

7 files changed

+34
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 75f4625bee530aed8a1bedd9523d68b26ddd2de1
1458+
refs/heads/master-rebranch: c87e1a23dbecc758e69fcc9f2f5a2e05959c80c5
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/include/swift/AST/Decl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class alignas(1 << DeclAlignInBits) Decl {
543543
NumRequirementsInSignature : 16
544544
);
545545

546-
SWIFT_INLINE_BITFIELD(ClassDecl, NominalTypeDecl, 2+1+2+1+7+1+1+1+1,
546+
SWIFT_INLINE_BITFIELD(ClassDecl, NominalTypeDecl, 2+1+2+1+7+1+1+1+1+1+1,
547547
/// The stage of the inheritance circularity check for this class.
548548
Circularity : 2,
549549

@@ -557,7 +557,10 @@ class alignas(1 << DeclAlignInBits) Decl {
557557
HasForcedEmittedMembers : 1,
558558

559559
HasMissingDesignatedInitializers : 1,
560+
ComputedHasMissingDesignatedInitializers : 1,
561+
560562
HasMissingVTableEntries : 1,
563+
ComputedHasMissingVTableEntries : 1,
561564

562565
/// Whether instances of this class are incompatible
563566
/// with weak and unowned references.
@@ -3879,6 +3882,7 @@ class ClassDecl final : public NominalTypeDecl {
38793882
bool hasMissingDesignatedInitializers() const;
38803883

38813884
void setHasMissingDesignatedInitializers(bool newValue = true) {
3885+
Bits.ClassDecl.ComputedHasMissingDesignatedInitializers = 1;
38823886
Bits.ClassDecl.HasMissingDesignatedInitializers = newValue;
38833887
}
38843888

@@ -3889,6 +3893,7 @@ class ClassDecl final : public NominalTypeDecl {
38893893
bool hasMissingVTableEntries() const;
38903894

38913895
void setHasMissingVTableEntries(bool newValue = true) {
3896+
Bits.ClassDecl.ComputedHasMissingVTableEntries = 1;
38923897
Bits.ClassDecl.HasMissingVTableEntries = newValue;
38933898
}
38943899

branches/master-rebranch/lib/AST/Decl.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,7 +3816,9 @@ ClassDecl::ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,
38163816
Bits.ClassDecl.InheritsSuperclassInits = 0;
38173817
Bits.ClassDecl.RawForeignKind = 0;
38183818
Bits.ClassDecl.HasMissingDesignatedInitializers = 0;
3819+
Bits.ClassDecl.ComputedHasMissingDesignatedInitializers = 0;
38193820
Bits.ClassDecl.HasMissingVTableEntries = 0;
3821+
Bits.ClassDecl.ComputedHasMissingVTableEntries = 0;
38203822
Bits.ClassDecl.IsIncompatibleWithWeakReferences = 0;
38213823
}
38223824

@@ -3901,16 +3903,25 @@ GetDestructorRequest::evaluate(Evaluator &evaluator, ClassDecl *CD) const {
39013903

39023904

39033905
bool ClassDecl::hasMissingDesignatedInitializers() const {
3904-
auto *mutableThis = const_cast<ClassDecl *>(this);
3905-
auto flags = OptionSet<LookupDirectFlags>();
3906-
flags |= LookupDirectFlags::IgnoreNewExtensions;
3907-
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor(),
3908-
flags);
3906+
if (!Bits.ClassDecl.ComputedHasMissingDesignatedInitializers) {
3907+
auto *mutableThis = const_cast<ClassDecl *>(this);
3908+
mutableThis->Bits.ClassDecl.ComputedHasMissingDesignatedInitializers = 1;
3909+
auto flags = OptionSet<LookupDirectFlags>();
3910+
flags |= LookupDirectFlags::IgnoreNewExtensions;
3911+
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor(),
3912+
flags);
3913+
}
3914+
39093915
return Bits.ClassDecl.HasMissingDesignatedInitializers;
39103916
}
39113917

39123918
bool ClassDecl::hasMissingVTableEntries() const {
3913-
(void)getMembers();
3919+
if (!Bits.ClassDecl.ComputedHasMissingVTableEntries) {
3920+
auto *mutableThis = const_cast<ClassDecl *>(this);
3921+
mutableThis->Bits.ClassDecl.ComputedHasMissingVTableEntries = 1;
3922+
mutableThis->loadAllMembers();
3923+
}
3924+
39143925
return Bits.ClassDecl.HasMissingVTableEntries;
39153926
}
39163927

branches/master-rebranch/lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4736,6 +4736,7 @@ namespace {
47364736
result->setCircularityCheck(CircularityCheck::Checked);
47374737
result->setSuperclass(Type());
47384738
result->setAddedImplicitInitializers(); // suppress all initializers
4739+
result->setHasMissingVTableEntries(false);
47394740
addObjCAttribute(result, Impl.importIdentifier(decl->getIdentifier()));
47404741
return result;
47414742
};
@@ -4903,6 +4904,7 @@ namespace {
49034904
if (decl->isArcWeakrefUnavailable())
49044905
result->setIsIncompatibleWithWeakReferences();
49054906

4907+
result->setHasMissingVTableEntries(false);
49064908
result->setMemberLoader(&Impl, 0);
49074909

49084910
return result;
@@ -5314,6 +5316,7 @@ SwiftDeclConverter::importCFClassType(const clang::TypedefNameDecl *decl,
53145316
theClass->setCircularityCheck(CircularityCheck::Checked);
53155317
theClass->setSuperclass(superclass);
53165318
theClass->setAddedImplicitInitializers(); // suppress all initializers
5319+
theClass->setHasMissingVTableEntries(false);
53175320
theClass->setForeignClassKind(ClassDecl::ForeignKind::CFType);
53185321
addObjCAttribute(theClass, None);
53195322

branches/master-rebranch/lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6119,6 +6119,9 @@ ParserResult<ClassDecl> Parser::parseDeclClass(ParseDeclOptions Flags,
61196119
setLocalDiscriminator(CD);
61206120
CD->getAttrs() = Attributes;
61216121

6122+
// Parsed classes never have missing vtable entries.
6123+
CD->setHasMissingVTableEntries(false);
6124+
61226125
ContextChange CC(*this, CD);
61236126

61246127
// Parse optional inheritance clause within the context of the class.

branches/master-rebranch/lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
833833

834834
// Bail out if we're validating one of our constructors or stored properties
835835
// already; we'll revisit the issue later.
836-
if (isa<ClassDecl>(decl)) {
836+
if (isa<ClassDecl>(decl) && !decl->hasClangNode()) {
837837
for (auto member : decl->getMembers()) {
838838
if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
839839
validateDecl(ctor);

branches/master-rebranch/lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
27562756
// we're doing here.
27572757
CD->walkSuperclasses(
27582758
[&](ClassDecl *superclass) {
2759+
if (!superclass->getParentSourceFile())
2760+
return TypeWalker::Action::Stop;
2761+
27592762
for (auto *member : superclass->getMembers()) {
27602763
if (auto *vd = dyn_cast<ValueDecl>(member)) {
27612764
if (vd->isPotentiallyOverridable()) {

0 commit comments

Comments
 (0)