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