Skip to content

Commit d14b6cb

Browse files
committed
---
yaml --- r: 349489 b: refs/heads/master-next c: da3fbf8 h: refs/heads/master i: 349487: 6bc07e4
1 parent afaec90 commit d14b6cb

File tree

7 files changed

+70
-21
lines changed

7 files changed

+70
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: a8231043f401c005c7ae877a43fd25a36b55c306
3+
refs/heads/master-next: da3fbf87b9de0bb7f9bfd2ca083a11e91df0170e
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ SWIFT_TYPEID(ResilienceExpansion)
2828
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>, PropertyWrapperMutability)
2929
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
3030
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)
31+
SWIFT_TYPEID(AncestryFlags)

branches/master-next/include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class VarDecl;
3131
class TypeAliasDecl;
3232
class Type;
3333
struct TypePair;
34+
enum class AncestryFlags : uint8_t;
3435

3536
#define SWIFT_AST_TYPEID_ZONE 1
3637

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,7 @@ class alignas(1 << DeclAlignInBits) Decl {
554554
RawForeignKind : 2,
555555

556556
/// \see ClassDecl::getEmittedMembers()
557-
HasForcedEmittedMembers : 1,
558-
559-
/// Information about the class's ancestry.
560-
Ancestry : 7,
561-
562-
/// Whether we have computed the above field or not.
563-
AncestryComputed : 1,
557+
HasForcedEmittedMembers : 1,
564558

565559
HasMissingDesignatedInitializers : 1,
566560
HasMissingVTableEntries : 1,

branches/master-next/include/swift/AST/TypeCheckRequests.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,27 @@ class IsImplicitlyUnwrappedOptionalRequest :
10521052
void cacheResult(bool value) const;
10531053
};
10541054

1055+
class ClassAncestryFlagsRequest :
1056+
public SimpleRequest<ClassAncestryFlagsRequest,
1057+
AncestryFlags (ClassDecl *),
1058+
CacheKind::Cached> {
1059+
public:
1060+
using SimpleRequest::SimpleRequest;
1061+
1062+
private:
1063+
friend SimpleRequest;
1064+
1065+
// Evaluation.
1066+
llvm::Expected<AncestryFlags>
1067+
evaluate(Evaluator &evaluator, ClassDecl *value) const;
1068+
1069+
public:
1070+
// Caching.
1071+
bool isCached() const { return true; }
1072+
};
1073+
1074+
void simple_display(llvm::raw_ostream &out, AncestryFlags value);
1075+
10551076
// Allow AnyValue to compare two Type values, even though Type doesn't
10561077
// support ==.
10571078
template<>

branches/master-next/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ SWIFT_TYPEID(RequiresOpaqueModifyCoroutineRequest)
5555
SWIFT_TYPEID(IsAccessorTransparentRequest)
5656
SWIFT_TYPEID(SynthesizeAccessorRequest)
5757
SWIFT_TYPEID(EmittedMembersRequest)
58-
SWIFT_TYPEID(IsImplicitlyUnwrappedOptionalRequest)
58+
SWIFT_TYPEID(IsImplicitlyUnwrappedOptionalRequest)
59+
SWIFT_TYPEID(ClassAncestryFlagsRequest)

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

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3808,8 +3808,6 @@ ClassDecl::ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,
38083808
= static_cast<unsigned>(CircularityCheck::Unchecked);
38093809
Bits.ClassDecl.InheritsSuperclassInits = 0;
38103810
Bits.ClassDecl.RawForeignKind = 0;
3811-
Bits.ClassDecl.Ancestry = 0;
3812-
Bits.ClassDecl.AncestryComputed = 0;
38133811
Bits.ClassDecl.HasMissingDesignatedInitializers = 0;
38143812
Bits.ClassDecl.HasMissingVTableEntries = 0;
38153813
Bits.ClassDecl.IsIncompatibleWithWeakReferences = 0;
@@ -3944,16 +3942,20 @@ bool ClassDecl::inheritsSuperclassInitializers() {
39443942
return Bits.ClassDecl.InheritsSuperclassInits;
39453943
}
39463944

3947-
AncestryOptions ClassDecl::checkAncestry() const {
3948-
// See if we've already computed this.
3949-
if (Bits.ClassDecl.AncestryComputed)
3950-
return AncestryOptions(Bits.ClassDecl.Ancestry);
39513945

3946+
AncestryOptions ClassDecl::checkAncestry() const {
3947+
return AncestryOptions(evaluateOrDefault(getASTContext().evaluator,
3948+
ClassAncestryFlagsRequest{const_cast<ClassDecl *>(this)},
3949+
AncestryFlags()));
3950+
}
3951+
3952+
llvm::Expected<AncestryFlags>
3953+
ClassAncestryFlagsRequest::evaluate(Evaluator &evaluator, ClassDecl *value) const {
39523954
llvm::SmallPtrSet<const ClassDecl *, 8> visited;
39533955

39543956
AncestryOptions result;
3955-
const ClassDecl *CD = this;
3956-
auto *M = getParentModule();
3957+
const ClassDecl *CD = value;
3958+
auto *M = value->getParentModule();
39573959

39583960
do {
39593961
// If we hit circularity, we will diagnose at some point in typeCheckDecl().
@@ -3988,10 +3990,39 @@ AncestryOptions ClassDecl::checkAncestry() const {
39883990
CD = CD->getSuperclassDecl();
39893991
} while (CD != nullptr);
39903992

3991-
// Save the result for later.
3992-
const_cast<ClassDecl *>(this)->Bits.ClassDecl.Ancestry = result.toRaw();
3993-
const_cast<ClassDecl *>(this)->Bits.ClassDecl.AncestryComputed = 1;
3994-
return result;
3993+
return AncestryFlags(result.toRaw());
3994+
}
3995+
3996+
void swift::simple_display(llvm::raw_ostream &out, AncestryFlags value) {
3997+
AncestryOptions opts(value);
3998+
out << "{ ";
3999+
// If we have more than one bit set, we need to print the separator.
4000+
bool wantsSeparator = false;
4001+
auto printBit = [&wantsSeparator, &out](bool val, StringRef name) {
4002+
if (wantsSeparator) {
4003+
out << ", ";
4004+
}
4005+
4006+
if (!wantsSeparator) {
4007+
wantsSeparator = true;
4008+
}
4009+
4010+
out << name;
4011+
if (val) {
4012+
out << " = true";
4013+
} else {
4014+
out << " = false";
4015+
}
4016+
};
4017+
printBit(opts.contains(AncestryFlags::ObjC), "ObjC");
4018+
printBit(opts.contains(AncestryFlags::ObjCMembers), "ObjCMembers");
4019+
printBit(opts.contains(AncestryFlags::Generic), "Generic");
4020+
printBit(opts.contains(AncestryFlags::Resilient), "Resilient");
4021+
printBit(opts.contains(AncestryFlags::ResilientOther), "ResilientOther");
4022+
printBit(opts.contains(AncestryFlags::ClangImported), "ClangImported");
4023+
printBit(opts.contains(AncestryFlags::RequiresStoredPropertyInits),
4024+
"RequiresStoredPropertyInits");
4025+
out << " }";
39954026
}
39964027

39974028
bool ClassDecl::isSuperclassOf(ClassDecl *other) const {

0 commit comments

Comments
 (0)