@@ -388,7 +388,7 @@ class alignas(1 << DeclAlignInBits) Decl {
388
388
SWIFT_INLINE_BITFIELD (SubscriptDecl, VarDecl, 2 ,
389
389
StaticSpelling : 2
390
390
);
391
- SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +8 +1 +1 +1 +1 +1 +1 + 1 + 1 ,
391
+ SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +8 +1 +1 +1 +1 +1 +1 ,
392
392
// / \see AbstractFunctionDecl::BodyKind
393
393
BodyKind : 3 ,
394
394
@@ -404,12 +404,6 @@ class alignas(1 << DeclAlignInBits) Decl {
404
404
// / Whether the function body throws.
405
405
Throws : 1 ,
406
406
407
- // / Whether this function requires a new vtable entry.
408
- NeedsNewVTableEntry : 1 ,
409
-
410
- // / Whether NeedsNewVTableEntry is valid.
411
- HasComputedNeedsNewVTableEntry : 1 ,
412
-
413
407
// / Whether this member was synthesized as part of a derived
414
408
// / protocol conformance.
415
409
Synthesized : 1 ,
@@ -418,10 +412,7 @@ class alignas(1 << DeclAlignInBits) Decl {
418
412
HasSingleExpressionBody : 1
419
413
);
420
414
421
- SWIFT_INLINE_BITFIELD (FuncDecl, AbstractFunctionDecl, 1 +1 +2 +1 +1 +2 ,
422
- // / Whether we've computed the 'static' flag yet.
423
- IsStaticComputed : 1 ,
424
-
415
+ SWIFT_INLINE_BITFIELD (FuncDecl, AbstractFunctionDecl, 1 +2 +1 +1 +2 ,
425
416
// / Whether this function is a 'static' method.
426
417
IsStatic : 1 ,
427
418
@@ -857,6 +848,17 @@ class alignas(1 << DeclAlignInBits) Decl {
857
848
return getValidationState () > ValidationState::Unchecked;
858
849
}
859
850
851
+ // / Manually indicate that validation is complete for the declaration. For
852
+ // / example: during importing, code synthesis, or derived conformances.
853
+ // /
854
+ // / For normal code validation, please use DeclValidationRAII instead.
855
+ // /
856
+ // / FIXME -- Everything should use DeclValidationRAII instead of this.
857
+ void setValidationToChecked () {
858
+ if (!isBeingValidated ())
859
+ Bits.Decl .ValidationState = unsigned (ValidationState::Checked);
860
+ }
861
+
860
862
bool escapedFromIfConfig () const {
861
863
return Bits.Decl .EscapedFromIfConfig ;
862
864
}
@@ -2597,9 +2599,6 @@ class ValueDecl : public Decl {
2597
2599
// / if the base declaration is \c open, the override might have to be too.
2598
2600
bool hasOpenAccess (const DeclContext *useDC) const ;
2599
2601
2600
- // / FIXME: This is deprecated.
2601
- bool isRecursiveValidation () const ;
2602
-
2603
2602
// / Retrieve the "interface" type of this value, which uses
2604
2603
// / GenericTypeParamType if the declaration is generic. For a generic
2605
2604
// / function, this will have a GenericFunctionType with a
@@ -2759,6 +2758,12 @@ class ValueDecl : public Decl {
2759
2758
// / Get the representative for this value's opaque result type, if it has one.
2760
2759
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr () const ;
2761
2760
2761
+ // / Set the opaque return type decl for this decl.
2762
+ // /
2763
+ // / `this` must be of a decl type that supports opaque return types, and
2764
+ // / must not have previously had an opaque result type set.
2765
+ void setOpaqueResultTypeDecl (OpaqueTypeDecl *D);
2766
+
2762
2767
// / Retrieve the attribute associating this declaration with a
2763
2768
// / function builder, if there is one.
2764
2769
CustomAttr *getAttachedFunctionBuilder () const ;
@@ -4519,6 +4524,8 @@ class AbstractStorageDecl : public ValueDecl {
4519
4524
Bits.AbstractStorageDecl .IsStatic = IsStatic;
4520
4525
}
4521
4526
4527
+ OpaqueTypeDecl *OpaqueReturn = nullptr ;
4528
+
4522
4529
public:
4523
4530
4524
4531
// / Should this declaration be treated as if annotated with transparent
@@ -4776,6 +4783,14 @@ class AbstractStorageDecl : public ValueDecl {
4776
4783
4777
4784
bool hasAnyDynamicReplacementAccessors () const ;
4778
4785
4786
+ OpaqueTypeDecl *getOpaqueResultTypeDecl () const {
4787
+ return OpaqueReturn;
4788
+ }
4789
+ void setOpaqueResultTypeDecl (OpaqueTypeDecl *decl) {
4790
+ assert (!OpaqueReturn && " already has opaque type decl" );
4791
+ OpaqueReturn = decl;
4792
+ }
4793
+
4779
4794
// Implement isa/cast/dyncast/etc.
4780
4795
static bool classof (const Decl *D) {
4781
4796
return D->getKind () >= DeclKind::First_AbstractStorageDecl &&
@@ -5553,6 +5568,8 @@ class ImportAsMemberStatus {
5553
5568
5554
5569
// / Base class for function-like declarations.
5555
5570
class AbstractFunctionDecl : public GenericContext , public ValueDecl {
5571
+ friend class NeedsNewVTableEntryRequest ;
5572
+
5556
5573
public:
5557
5574
enum class BodyKind {
5558
5575
// / The function did not have a body in the source code file.
@@ -5622,6 +5639,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5622
5639
// / Location of the 'throws' token.
5623
5640
SourceLoc ThrowsLoc;
5624
5641
5642
+ struct {
5643
+ unsigned NeedsNewVTableEntryComputed : 1 ;
5644
+ unsigned NeedsNewVTableEntry : 1 ;
5645
+ } LazySemanticInfo = { };
5646
+
5625
5647
AbstractFunctionDecl (DeclKind Kind, DeclContext *Parent, DeclName Name,
5626
5648
SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,
5627
5649
bool HasImplicitSelfDecl,
@@ -5633,8 +5655,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5633
5655
Bits.AbstractFunctionDecl .HasImplicitSelfDecl = HasImplicitSelfDecl;
5634
5656
Bits.AbstractFunctionDecl .Overridden = false ;
5635
5657
Bits.AbstractFunctionDecl .Throws = Throws;
5636
- Bits.AbstractFunctionDecl .NeedsNewVTableEntry = false ;
5637
- Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry = false ;
5638
5658
Bits.AbstractFunctionDecl .Synthesized = false ;
5639
5659
Bits.AbstractFunctionDecl .HasSingleExpressionBody = false ;
5640
5660
}
@@ -5805,15 +5825,13 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5805
5825
}
5806
5826
5807
5827
void setNeedsNewVTableEntry (bool value) {
5808
- Bits. AbstractFunctionDecl . HasComputedNeedsNewVTableEntry = true ;
5809
- Bits. AbstractFunctionDecl .NeedsNewVTableEntry = value;
5828
+ LazySemanticInfo. NeedsNewVTableEntryComputed = true ;
5829
+ LazySemanticInfo .NeedsNewVTableEntry = value;
5810
5830
}
5811
5831
5812
- bool needsNewVTableEntry () const {
5813
- if (!Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry )
5814
- const_cast <AbstractFunctionDecl *>(this )->computeNeedsNewVTableEntry ();
5815
- return Bits.AbstractFunctionDecl .NeedsNewVTableEntry ;
5816
- }
5832
+ // / For a method of a class, checks whether it will require a new entry in the
5833
+ // / vtable.
5834
+ bool needsNewVTableEntry () const ;
5817
5835
5818
5836
bool isEffectiveLinkageMoreVisibleThan (ValueDecl *other) const {
5819
5837
return (std::min (getEffectiveAccess (), AccessLevel::Public) >
@@ -5955,13 +5973,14 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
5955
5973
class FuncDecl : public AbstractFunctionDecl {
5956
5974
friend class AbstractFunctionDecl ;
5957
5975
friend class SelfAccessKindRequest ;
5958
- friend class IsStaticRequest ;
5959
5976
5960
5977
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
5961
5978
SourceLoc FuncLoc; // Location of the 'func' token.
5962
5979
5963
5980
TypeLoc FnRetType;
5964
5981
5982
+ OpaqueTypeDecl *OpaqueReturn = nullptr ;
5983
+
5965
5984
protected:
5966
5985
FuncDecl (DeclKind Kind,
5967
5986
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -5977,14 +5996,14 @@ class FuncDecl : public AbstractFunctionDecl {
5977
5996
StaticLoc (StaticLoc), FuncLoc(FuncLoc) {
5978
5997
assert (!Name.getBaseName ().isSpecial ());
5979
5998
5999
+ Bits.FuncDecl .IsStatic =
6000
+ StaticLoc.isValid () || StaticSpelling != StaticSpellingKind::None;
5980
6001
Bits.FuncDecl .StaticSpelling = static_cast <unsigned >(StaticSpelling);
5981
6002
5982
6003
Bits.FuncDecl .ForcedStaticDispatch = false ;
5983
6004
Bits.FuncDecl .SelfAccess =
5984
6005
static_cast <unsigned >(SelfAccessKind::NonMutating);
5985
6006
Bits.FuncDecl .SelfAccessComputed = false ;
5986
- Bits.FuncDecl .IsStaticComputed = false ;
5987
- Bits.FuncDecl .IsStatic = false ;
5988
6007
}
5989
6008
5990
6009
private:
@@ -6004,13 +6023,6 @@ class FuncDecl : public AbstractFunctionDecl {
6004
6023
return None;
6005
6024
}
6006
6025
6007
- Optional<bool > getCachedIsStatic () const {
6008
- if (Bits.FuncDecl .IsStaticComputed )
6009
- return Bits.FuncDecl .IsStatic ;
6010
-
6011
- return None;
6012
- }
6013
-
6014
6026
public:
6015
6027
// / Factory function only for use by deserialization.
6016
6028
static FuncDecl *createDeserialized (ASTContext &Context, SourceLoc StaticLoc,
@@ -6033,16 +6045,16 @@ class FuncDecl : public AbstractFunctionDecl {
6033
6045
6034
6046
Identifier getName () const { return getFullName ().getBaseIdentifier (); }
6035
6047
6036
- bool isStatic () const ;
6037
-
6048
+ bool isStatic () const {
6049
+ return Bits.FuncDecl .IsStatic ;
6050
+ }
6038
6051
// / \returns the way 'static'/'class' was spelled in the source.
6039
6052
StaticSpellingKind getStaticSpelling () const {
6040
6053
return static_cast <StaticSpellingKind>(Bits.FuncDecl .StaticSpelling );
6041
6054
}
6042
6055
// / \returns the way 'static'/'class' should be spelled for this declaration.
6043
6056
StaticSpellingKind getCorrectStaticSpelling () const ;
6044
6057
void setStatic (bool IsStatic = true ) {
6045
- Bits.FuncDecl .IsStaticComputed = true ;
6046
6058
Bits.FuncDecl .IsStatic = IsStatic;
6047
6059
}
6048
6060
@@ -6114,7 +6126,15 @@ class FuncDecl : public AbstractFunctionDecl {
6114
6126
}
6115
6127
6116
6128
OperatorDecl *getOperatorDecl () const ;
6117
-
6129
+
6130
+ OpaqueTypeDecl *getOpaqueResultTypeDecl () const {
6131
+ return OpaqueReturn;
6132
+ }
6133
+ void setOpaqueResultTypeDecl (OpaqueTypeDecl *decl) {
6134
+ assert (!OpaqueReturn && " already has opaque type decl" );
6135
+ OpaqueReturn = decl;
6136
+ }
6137
+
6118
6138
// / Returns true if the function is forced to be statically dispatched.
6119
6139
bool hasForcedStaticDispatch () const {
6120
6140
return Bits.FuncDecl .ForcedStaticDispatch ;
0 commit comments