@@ -445,9 +445,15 @@ class alignas(1 << DeclAlignInBits) Decl {
445
445
SelfAccess : 2
446
446
);
447
447
448
- SWIFT_INLINE_BITFIELD (AccessorDecl, FuncDecl, 4 ,
448
+ SWIFT_INLINE_BITFIELD (AccessorDecl, FuncDecl, 4 + 1 + 1 ,
449
449
// / The kind of accessor this is.
450
- AccessorKind : 4
450
+ AccessorKind : 4 ,
451
+
452
+ // / Whether the accessor is transparent.
453
+ IsTransparent : 1 ,
454
+
455
+ // / Whether we have computed the above.
456
+ IsTransparentComputed : 1
451
457
);
452
458
453
459
SWIFT_INLINE_BITFIELD (ConstructorDecl, AbstractFunctionDecl, 3 +2 +1 ,
@@ -2582,12 +2588,6 @@ class ValueDecl : public Decl {
2582
2588
void setInterfaceType (Type type);
2583
2589
2584
2590
bool hasValidSignature () const ;
2585
-
2586
- // / isSettable - Determine whether references to this decl may appear
2587
- // / on the left-hand side of an assignment or as the operand of a
2588
- // / `&` or 'inout' operator.
2589
- bool isSettable (const DeclContext *UseDC,
2590
- const DeclRefExpr *base = nullptr ) const ;
2591
2591
2592
2592
// / isInstanceMember - Determine whether this value is an instance member
2593
2593
// / of an enum or protocol.
@@ -4389,6 +4389,9 @@ class AbstractStorageDecl : public ValueDecl {
4389
4389
friend class IsSetterMutatingRequest ;
4390
4390
friend class OpaqueReadOwnershipRequest ;
4391
4391
friend class StorageImplInfoRequest ;
4392
+ friend class RequiresOpaqueAccessorsRequest ;
4393
+ friend class RequiresOpaqueModifyCoroutineRequest ;
4394
+ friend class SynthesizeAccessorRequest ;
4392
4395
4393
4396
public:
4394
4397
static const size_t MaxNumAccessors = 255 ;
@@ -4452,11 +4455,18 @@ class AbstractStorageDecl : public ValueDecl {
4452
4455
unsigned OpaqueReadOwnershipComputed : 1 ;
4453
4456
unsigned OpaqueReadOwnership : 2 ;
4454
4457
unsigned ImplInfoComputed : 1 ;
4458
+ unsigned RequiresOpaqueAccessorsComputed : 1 ;
4459
+ unsigned RequiresOpaqueAccessors : 1 ;
4460
+ unsigned RequiresOpaqueModifyCoroutineComputed : 1 ;
4461
+ unsigned RequiresOpaqueModifyCoroutine : 1 ;
4455
4462
} LazySemanticInfo = { };
4456
4463
4457
4464
// / The implementation info for the accessors.
4458
4465
StorageImplInfo ImplInfo;
4459
4466
4467
+ // / Add a synthesized accessor.
4468
+ void setSynthesizedAccessor (AccessorKind kind, AccessorDecl *getter);
4469
+
4460
4470
protected:
4461
4471
AbstractStorageDecl (DeclKind Kind, bool IsStatic, DeclContext *DC,
4462
4472
DeclName Name, SourceLoc NameLoc,
@@ -4530,6 +4540,12 @@ class AbstractStorageDecl : public ValueDecl {
4530
4540
return getImplInfo ().supportsMutation ();
4531
4541
}
4532
4542
4543
+ // / isSettable - Determine whether references to this decl may appear
4544
+ // / on the left-hand side of an assignment or as the operand of a
4545
+ // / `&` or 'inout' operator.
4546
+ bool isSettable (const DeclContext *UseDC,
4547
+ const DeclRefExpr *base = nullptr ) const ;
4548
+
4533
4549
// / Are there any accessors for this declaration, including implicit ones?
4534
4550
bool hasAnyAccessors () const {
4535
4551
return !getAllAccessors ().empty ();
@@ -4570,6 +4586,12 @@ class AbstractStorageDecl : public ValueDecl {
4570
4586
return {};
4571
4587
}
4572
4588
4589
+ // / Return an accessor that this storage is expected to have, synthesizing
4590
+ // / one if necessary. Note that will always synthesize one, even if the
4591
+ // / accessor is not part of the expected opaque set for the storage, so use
4592
+ // / with caution.
4593
+ AccessorDecl *getSynthesizedAccessor (AccessorKind kind) const ;
4594
+
4573
4595
// / Visit all the opaque accessors that this storage is expected to have.
4574
4596
void visitExpectedOpaqueAccessors (
4575
4597
llvm::function_ref<void (AccessorKind)>) const ;
@@ -4585,17 +4607,8 @@ class AbstractStorageDecl : public ValueDecl {
4585
4607
// / This should only be used by the ClangImporter.
4586
4608
void setComputedSetter (AccessorDecl *Set);
4587
4609
4588
- // / Add a synthesized getter.
4589
- void setSynthesizedGetter (AccessorDecl *getter);
4590
-
4591
- // / Add a synthesized setter.
4592
- void setSynthesizedSetter (AccessorDecl *setter);
4593
-
4594
- // / Add a synthesized read coroutine.
4595
- void setSynthesizedReadCoroutine (AccessorDecl *read);
4596
-
4597
- // / Add a synthesized modify coroutine.
4598
- void setSynthesizedModifyCoroutine (AccessorDecl *modify);
4610
+ // / Does this storage require opaque accessors of any kind?
4611
+ bool requiresOpaqueAccessors () const ;
4599
4612
4600
4613
// / Does this storage require an opaque accessor of the given kind?
4601
4614
bool requiresOpaqueAccessor (AccessorKind kind) const ;
@@ -4634,6 +4647,10 @@ class AbstractStorageDecl : public ValueDecl {
4634
4647
4635
4648
AccessLevel getSetterFormalAccess () const ;
4636
4649
4650
+ AccessScope
4651
+ getSetterFormalAccessScope (const DeclContext *useDC = nullptr ,
4652
+ bool treatUsableFromInlineAsPublic = false ) const ;
4653
+
4637
4654
void setSetterAccess (AccessLevel accessLevel) {
4638
4655
assert (!Accessors.getInt ().hasValue ());
4639
4656
overwriteSetterAccess (accessLevel);
@@ -5472,9 +5489,6 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
5472
5489
// / element types.
5473
5490
void computeType ();
5474
5491
5475
- // / Returns whether the result of the subscript operation can be set.
5476
- bool isSettable () const ;
5477
-
5478
5492
// / Determine the kind of Objective-C subscripting this declaration
5479
5493
// / implies.
5480
5494
ObjCSubscriptKind getObjCSubscriptKind () const ;
@@ -5853,10 +5867,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5853
5867
return cast_or_null<AbstractFunctionDecl>(ValueDecl::getOverriddenDecl ());
5854
5868
}
5855
5869
5856
- // / Returns true if a function declaration overrides a given
5857
- // / method from its direct or indirect superclass.
5858
- bool isOverridingDecl (const AbstractFunctionDecl *method) const ;
5859
-
5860
5870
// / Whether the declaration is later overridden in the module
5861
5871
// /
5862
5872
// / Overrides are resolved during type checking; only query this field after
@@ -6155,6 +6165,14 @@ class AccessorDecl final : public FuncDecl {
6155
6165
DeclContext *parent,
6156
6166
ClangNode clangNode);
6157
6167
6168
+ Optional<bool > getCachedIsTransparent () const {
6169
+ if (Bits.AccessorDecl .IsTransparentComputed )
6170
+ return Bits.AccessorDecl .IsTransparent ;
6171
+ return None;
6172
+ }
6173
+
6174
+ friend class IsAccessorTransparentRequest ;
6175
+
6158
6176
public:
6159
6177
static AccessorDecl *createDeserialized (ASTContext &ctx,
6160
6178
SourceLoc declLoc,
@@ -6233,6 +6251,11 @@ class AccessorDecl final : public FuncDecl {
6233
6251
llvm_unreachable (" bad accessor kind" );
6234
6252
}
6235
6253
6254
+ void setIsTransparent (bool transparent) {
6255
+ Bits.AccessorDecl .IsTransparent = transparent;
6256
+ Bits.AccessorDecl .IsTransparentComputed = 1 ;
6257
+ }
6258
+
6236
6259
static bool classof (const Decl *D) {
6237
6260
return D->getKind () == DeclKind::Accessor;
6238
6261
}
@@ -7041,22 +7064,14 @@ class MissingMemberDecl : public Decl {
7041
7064
}
7042
7065
public:
7043
7066
static MissingMemberDecl *
7044
- forMethod (ASTContext &ctx, DeclContext *DC, DeclName name,
7045
- bool hasNormalVTableEntry) {
7046
- assert (!name || name.isCompoundName ());
7047
- return new (ctx) MissingMemberDecl (DC, name, hasNormalVTableEntry, 0 );
7048
- }
7067
+ create (ASTContext &ctx, DeclContext *DC, DeclName name,
7068
+ unsigned numVTableEntries, bool hasStorage) {
7069
+ assert (!numVTableEntries || isa<ProtocolDecl>(DC) || isa<ClassDecl>(DC) &&
7070
+ " Only classes and protocols have vtable/witness table entries" );
7071
+ assert (!hasStorage || !isa<ProtocolDecl>(DC) &&
7072
+ " Protocols cannot have missing stored properties" );
7049
7073
7050
- static MissingMemberDecl *
7051
- forInitializer (ASTContext &ctx, DeclContext *DC, DeclName name,
7052
- bool hasVTableEntry) {
7053
- unsigned entries = hasVTableEntry ? 1 : 0 ;
7054
- return new (ctx) MissingMemberDecl (DC, name, entries, 0 );
7055
- }
7056
-
7057
- static MissingMemberDecl *
7058
- forStoredProperty (ASTContext &ctx, DeclContext *DC, DeclName name) {
7059
- return new (ctx) MissingMemberDecl (DC, name, 0 , 1 );
7074
+ return new (ctx) MissingMemberDecl (DC, name, numVTableEntries, hasStorage);
7060
7075
}
7061
7076
7062
7077
DeclName getFullName () const {
@@ -7084,14 +7099,13 @@ class MissingMemberDecl : public Decl {
7084
7099
}
7085
7100
};
7086
7101
7087
- inline bool ValueDecl ::isSettable (const DeclContext *UseDC,
7088
- const DeclRefExpr *base) const {
7089
- if (auto vd = dyn_cast<VarDecl>(this )) {
7102
+ inline bool AbstractStorageDecl ::isSettable (const DeclContext *UseDC,
7103
+ const DeclRefExpr *base) const {
7104
+ if (auto vd = dyn_cast<VarDecl>(this ))
7090
7105
return vd->isSettable (UseDC, base);
7091
- } else if (auto sd = dyn_cast<SubscriptDecl>(this )) {
7092
- return sd->isSettable ();
7093
- } else
7094
- return false ;
7106
+
7107
+ auto sd = cast<SubscriptDecl>(this );
7108
+ return sd->supportsMutation ();
7095
7109
}
7096
7110
7097
7111
inline void
0 commit comments