@@ -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 ,
391
+ SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +8 +1 +1 +1 +1 +1 +1 + 1 + 1 ,
392
392
// / \see AbstractFunctionDecl::BodyKind
393
393
BodyKind : 3 ,
394
394
@@ -404,6 +404,12 @@ 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
+
407
413
// / Whether this member was synthesized as part of a derived
408
414
// / protocol conformance.
409
415
Synthesized : 1 ,
@@ -412,10 +418,7 @@ class alignas(1 << DeclAlignInBits) Decl {
412
418
HasSingleExpressionBody : 1
413
419
);
414
420
415
- SWIFT_INLINE_BITFIELD (FuncDecl, AbstractFunctionDecl, 1 +1 +2 +1 +1 +2 ,
416
- // / Whether we've computed the 'static' flag yet.
417
- IsStaticComputed : 1 ,
418
-
421
+ SWIFT_INLINE_BITFIELD (FuncDecl, AbstractFunctionDecl, 1 +2 +1 +1 +2 ,
419
422
// / Whether this function is a 'static' method.
420
423
IsStatic : 1 ,
421
424
@@ -851,6 +854,17 @@ class alignas(1 << DeclAlignInBits) Decl {
851
854
return getValidationState () > ValidationState::Unchecked;
852
855
}
853
856
857
+ // / Manually indicate that validation is complete for the declaration. For
858
+ // / example: during importing, code synthesis, or derived conformances.
859
+ // /
860
+ // / For normal code validation, please use DeclValidationRAII instead.
861
+ // /
862
+ // / FIXME -- Everything should use DeclValidationRAII instead of this.
863
+ void setValidationToChecked () {
864
+ if (!isBeingValidated ())
865
+ Bits.Decl .ValidationState = unsigned (ValidationState::Checked);
866
+ }
867
+
854
868
bool escapedFromIfConfig () const {
855
869
return Bits.Decl .EscapedFromIfConfig ;
856
870
}
@@ -2591,9 +2605,6 @@ class ValueDecl : public Decl {
2591
2605
// / if the base declaration is \c open, the override might have to be too.
2592
2606
bool hasOpenAccess (const DeclContext *useDC) const ;
2593
2607
2594
- // / FIXME: This is deprecated.
2595
- bool isRecursiveValidation () const ;
2596
-
2597
2608
// / Retrieve the "interface" type of this value, which uses
2598
2609
// / GenericTypeParamType if the declaration is generic. For a generic
2599
2610
// / function, this will have a GenericFunctionType with a
@@ -2753,6 +2764,12 @@ class ValueDecl : public Decl {
2753
2764
// / Get the representative for this value's opaque result type, if it has one.
2754
2765
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr () const ;
2755
2766
2767
+ // / Set the opaque return type decl for this decl.
2768
+ // /
2769
+ // / `this` must be of a decl type that supports opaque return types, and
2770
+ // / must not have previously had an opaque result type set.
2771
+ void setOpaqueResultTypeDecl (OpaqueTypeDecl *D);
2772
+
2756
2773
// / Retrieve the attribute associating this declaration with a
2757
2774
// / function builder, if there is one.
2758
2775
CustomAttr *getAttachedFunctionBuilder () const ;
@@ -4513,6 +4530,8 @@ class AbstractStorageDecl : public ValueDecl {
4513
4530
Bits.AbstractStorageDecl .IsStatic = IsStatic;
4514
4531
}
4515
4532
4533
+ OpaqueTypeDecl *OpaqueReturn = nullptr ;
4534
+
4516
4535
public:
4517
4536
4518
4537
// / Should this declaration be treated as if annotated with transparent
@@ -4770,6 +4789,14 @@ class AbstractStorageDecl : public ValueDecl {
4770
4789
4771
4790
bool hasAnyDynamicReplacementAccessors () const ;
4772
4791
4792
+ OpaqueTypeDecl *getOpaqueResultTypeDecl () const {
4793
+ return OpaqueReturn;
4794
+ }
4795
+ void setOpaqueResultTypeDecl (OpaqueTypeDecl *decl) {
4796
+ assert (!OpaqueReturn && " already has opaque type decl" );
4797
+ OpaqueReturn = decl;
4798
+ }
4799
+
4773
4800
// Implement isa/cast/dyncast/etc.
4774
4801
static bool classof (const Decl *D) {
4775
4802
return D->getKind () >= DeclKind::First_AbstractStorageDecl &&
@@ -5547,8 +5574,6 @@ class ImportAsMemberStatus {
5547
5574
5548
5575
// / Base class for function-like declarations.
5549
5576
class AbstractFunctionDecl : public GenericContext , public ValueDecl {
5550
- friend class NeedsNewVTableEntryRequest ;
5551
-
5552
5577
public:
5553
5578
enum class BodyKind {
5554
5579
// / The function did not have a body in the source code file.
@@ -5618,11 +5643,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5618
5643
// / Location of the 'throws' token.
5619
5644
SourceLoc ThrowsLoc;
5620
5645
5621
- struct {
5622
- unsigned NeedsNewVTableEntryComputed : 1 ;
5623
- unsigned NeedsNewVTableEntry : 1 ;
5624
- } LazySemanticInfo = { };
5625
-
5626
5646
AbstractFunctionDecl (DeclKind Kind, DeclContext *Parent, DeclName Name,
5627
5647
SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,
5628
5648
bool HasImplicitSelfDecl,
@@ -5634,6 +5654,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5634
5654
Bits.AbstractFunctionDecl .HasImplicitSelfDecl = HasImplicitSelfDecl;
5635
5655
Bits.AbstractFunctionDecl .Overridden = false ;
5636
5656
Bits.AbstractFunctionDecl .Throws = Throws;
5657
+ Bits.AbstractFunctionDecl .NeedsNewVTableEntry = false ;
5658
+ Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry = false ;
5637
5659
Bits.AbstractFunctionDecl .Synthesized = false ;
5638
5660
Bits.AbstractFunctionDecl .HasSingleExpressionBody = false ;
5639
5661
}
@@ -5803,9 +5825,16 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5803
5825
return getBodyKind () == BodyKind::MemberwiseInitializer;
5804
5826
}
5805
5827
5806
- // / For a method of a class, checks whether it will require a new entry in the
5807
- // / vtable.
5808
- bool needsNewVTableEntry () const ;
5828
+ void setNeedsNewVTableEntry (bool value) {
5829
+ Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry = true ;
5830
+ Bits.AbstractFunctionDecl .NeedsNewVTableEntry = value;
5831
+ }
5832
+
5833
+ bool needsNewVTableEntry () const {
5834
+ if (!Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry )
5835
+ const_cast <AbstractFunctionDecl *>(this )->computeNeedsNewVTableEntry ();
5836
+ return Bits.AbstractFunctionDecl .NeedsNewVTableEntry ;
5837
+ }
5809
5838
5810
5839
bool isEffectiveLinkageMoreVisibleThan (ValueDecl *other) const {
5811
5840
return (std::min (getEffectiveAccess (), AccessLevel::Public) >
@@ -5947,13 +5976,14 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
5947
5976
class FuncDecl : public AbstractFunctionDecl {
5948
5977
friend class AbstractFunctionDecl ;
5949
5978
friend class SelfAccessKindRequest ;
5950
- friend class IsStaticRequest ;
5951
5979
5952
5980
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
5953
5981
SourceLoc FuncLoc; // Location of the 'func' token.
5954
5982
5955
5983
TypeLoc FnRetType;
5956
5984
5985
+ OpaqueTypeDecl *OpaqueReturn = nullptr ;
5986
+
5957
5987
protected:
5958
5988
FuncDecl (DeclKind Kind,
5959
5989
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -5969,14 +5999,14 @@ class FuncDecl : public AbstractFunctionDecl {
5969
5999
StaticLoc (StaticLoc), FuncLoc(FuncLoc) {
5970
6000
assert (!Name.getBaseName ().isSpecial ());
5971
6001
6002
+ Bits.FuncDecl .IsStatic =
6003
+ StaticLoc.isValid () || StaticSpelling != StaticSpellingKind::None;
5972
6004
Bits.FuncDecl .StaticSpelling = static_cast <unsigned >(StaticSpelling);
5973
6005
5974
6006
Bits.FuncDecl .ForcedStaticDispatch = false ;
5975
6007
Bits.FuncDecl .SelfAccess =
5976
6008
static_cast <unsigned >(SelfAccessKind::NonMutating);
5977
6009
Bits.FuncDecl .SelfAccessComputed = false ;
5978
- Bits.FuncDecl .IsStaticComputed = false ;
5979
- Bits.FuncDecl .IsStatic = false ;
5980
6010
}
5981
6011
5982
6012
private:
@@ -5996,13 +6026,6 @@ class FuncDecl : public AbstractFunctionDecl {
5996
6026
return None;
5997
6027
}
5998
6028
5999
- Optional<bool > getCachedIsStatic () const {
6000
- if (Bits.FuncDecl .IsStaticComputed )
6001
- return Bits.FuncDecl .IsStatic ;
6002
-
6003
- return None;
6004
- }
6005
-
6006
6029
public:
6007
6030
// / Factory function only for use by deserialization.
6008
6031
static FuncDecl *createDeserialized (ASTContext &Context, SourceLoc StaticLoc,
@@ -6025,16 +6048,16 @@ class FuncDecl : public AbstractFunctionDecl {
6025
6048
6026
6049
Identifier getName () const { return getFullName ().getBaseIdentifier (); }
6027
6050
6028
- bool isStatic () const ;
6029
-
6051
+ bool isStatic () const {
6052
+ return Bits.FuncDecl .IsStatic ;
6053
+ }
6030
6054
// / \returns the way 'static'/'class' was spelled in the source.
6031
6055
StaticSpellingKind getStaticSpelling () const {
6032
6056
return static_cast <StaticSpellingKind>(Bits.FuncDecl .StaticSpelling );
6033
6057
}
6034
6058
// / \returns the way 'static'/'class' should be spelled for this declaration.
6035
6059
StaticSpellingKind getCorrectStaticSpelling () const ;
6036
6060
void setStatic (bool IsStatic = true ) {
6037
- Bits.FuncDecl .IsStaticComputed = true ;
6038
6061
Bits.FuncDecl .IsStatic = IsStatic;
6039
6062
}
6040
6063
@@ -6106,7 +6129,15 @@ class FuncDecl : public AbstractFunctionDecl {
6106
6129
}
6107
6130
6108
6131
OperatorDecl *getOperatorDecl () const ;
6109
-
6132
+
6133
+ OpaqueTypeDecl *getOpaqueResultTypeDecl () const {
6134
+ return OpaqueReturn;
6135
+ }
6136
+ void setOpaqueResultTypeDecl (OpaqueTypeDecl *decl) {
6137
+ assert (!OpaqueReturn && " already has opaque type decl" );
6138
+ OpaqueReturn = decl;
6139
+ }
6140
+
6110
6141
// / Returns true if the function is forced to be statically dispatched.
6111
6142
bool hasForcedStaticDispatch () const {
6112
6143
return Bits.FuncDecl .ForcedStaticDispatch ;
0 commit comments