@@ -340,12 +340,7 @@ class alignas(1 << DeclAlignInBits) Decl {
340
340
IsUserAccessible : 1
341
341
);
342
342
343
- SWIFT_INLINE_BITFIELD (AbstractStorageDecl, ValueDecl, 1 +1 +1 ,
344
- // / Whether a keypath component can directly reference this storage,
345
- // / or if it must use the overridden declaration instead.
346
- HasComputedValidKeyPathComponent : 1 ,
347
- ValidKeyPathComponent : 1 ,
348
-
343
+ SWIFT_INLINE_BITFIELD (AbstractStorageDecl, ValueDecl, 1 ,
349
344
// / Whether this property is a type property (currently unfortunately
350
345
// / called 'static').
351
346
IsStatic : 1
@@ -393,7 +388,7 @@ class alignas(1 << DeclAlignInBits) Decl {
393
388
SWIFT_INLINE_BITFIELD (SubscriptDecl, VarDecl, 2 ,
394
389
StaticSpelling : 2
395
390
);
396
- 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 ,
397
392
// / \see AbstractFunctionDecl::BodyKind
398
393
BodyKind : 3 ,
399
394
@@ -409,12 +404,6 @@ class alignas(1 << DeclAlignInBits) Decl {
409
404
// / Whether the function body throws.
410
405
Throws : 1 ,
411
406
412
- // / Whether this function requires a new vtable entry.
413
- NeedsNewVTableEntry : 1 ,
414
-
415
- // / Whether NeedsNewVTableEntry is valid.
416
- HasComputedNeedsNewVTableEntry : 1 ,
417
-
418
407
// / Whether this member was synthesized as part of a derived
419
408
// / protocol conformance.
420
409
Synthesized : 1 ,
@@ -423,7 +412,10 @@ class alignas(1 << DeclAlignInBits) Decl {
423
412
HasSingleExpressionBody : 1
424
413
);
425
414
426
- 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
+
427
419
// / Whether this function is a 'static' method.
428
420
IsStatic : 1 ,
429
421
@@ -859,17 +851,6 @@ class alignas(1 << DeclAlignInBits) Decl {
859
851
return getValidationState () > ValidationState::Unchecked;
860
852
}
861
853
862
- // / Manually indicate that validation is complete for the declaration. For
863
- // / example: during importing, code synthesis, or derived conformances.
864
- // /
865
- // / For normal code validation, please use DeclValidationRAII instead.
866
- // /
867
- // / FIXME -- Everything should use DeclValidationRAII instead of this.
868
- void setValidationToChecked () {
869
- if (!isBeingValidated ())
870
- Bits.Decl .ValidationState = unsigned (ValidationState::Checked);
871
- }
872
-
873
854
bool escapedFromIfConfig () const {
874
855
return Bits.Decl .EscapedFromIfConfig ;
875
856
}
@@ -2610,6 +2591,9 @@ class ValueDecl : public Decl {
2610
2591
// / if the base declaration is \c open, the override might have to be too.
2611
2592
bool hasOpenAccess (const DeclContext *useDC) const ;
2612
2593
2594
+ // / FIXME: This is deprecated.
2595
+ bool isRecursiveValidation () const ;
2596
+
2613
2597
// / Retrieve the "interface" type of this value, which uses
2614
2598
// / GenericTypeParamType if the declaration is generic. For a generic
2615
2599
// / function, this will have a GenericFunctionType with a
@@ -2769,12 +2753,6 @@ class ValueDecl : public Decl {
2769
2753
// / Get the representative for this value's opaque result type, if it has one.
2770
2754
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr () const ;
2771
2755
2772
- // / Set the opaque return type decl for this decl.
2773
- // /
2774
- // / `this` must be of a decl type that supports opaque return types, and
2775
- // / must not have previously had an opaque result type set.
2776
- void setOpaqueResultTypeDecl (OpaqueTypeDecl *D);
2777
-
2778
2756
// / Retrieve the attribute associating this declaration with a
2779
2757
// / function builder, if there is one.
2780
2758
CustomAttr *getAttachedFunctionBuilder () const ;
@@ -4535,10 +4513,6 @@ class AbstractStorageDecl : public ValueDecl {
4535
4513
Bits.AbstractStorageDecl .IsStatic = IsStatic;
4536
4514
}
4537
4515
4538
- void computeIsValidKeyPathComponent ();
4539
-
4540
- OpaqueTypeDecl *OpaqueReturn = nullptr ;
4541
-
4542
4516
public:
4543
4517
4544
4518
// / Should this declaration be treated as if annotated with transparent
@@ -4779,18 +4753,9 @@ class AbstractStorageDecl : public ValueDecl {
4779
4753
// / property from the given module?
4780
4754
bool isResilient (ModuleDecl *M, ResilienceExpansion expansion) const ;
4781
4755
4782
- void setIsValidKeyPathComponent (bool value) {
4783
- Bits.AbstractStorageDecl .HasComputedValidKeyPathComponent = true ;
4784
- Bits.AbstractStorageDecl .ValidKeyPathComponent = value;
4785
- }
4786
-
4787
4756
// / True if the storage can be referenced by a keypath directly.
4788
4757
// / Otherwise, its override must be referenced.
4789
- bool isValidKeyPathComponent () const {
4790
- if (!Bits.AbstractStorageDecl .HasComputedValidKeyPathComponent )
4791
- const_cast <AbstractStorageDecl *>(this )->computeIsValidKeyPathComponent ();
4792
- return Bits.AbstractStorageDecl .ValidKeyPathComponent ;
4793
- }
4758
+ bool isValidKeyPathComponent () const ;
4794
4759
4795
4760
// / True if the storage exports a property descriptor for key paths in
4796
4761
// / other modules.
@@ -4805,14 +4770,6 @@ class AbstractStorageDecl : public ValueDecl {
4805
4770
4806
4771
bool hasAnyDynamicReplacementAccessors () const ;
4807
4772
4808
- OpaqueTypeDecl *getOpaqueResultTypeDecl () const {
4809
- return OpaqueReturn;
4810
- }
4811
- void setOpaqueResultTypeDecl (OpaqueTypeDecl *decl) {
4812
- assert (!OpaqueReturn && " already has opaque type decl" );
4813
- OpaqueReturn = decl;
4814
- }
4815
-
4816
4773
// Implement isa/cast/dyncast/etc.
4817
4774
static bool classof (const Decl *D) {
4818
4775
return D->getKind () >= DeclKind::First_AbstractStorageDecl &&
@@ -5590,6 +5547,8 @@ class ImportAsMemberStatus {
5590
5547
5591
5548
// / Base class for function-like declarations.
5592
5549
class AbstractFunctionDecl : public GenericContext , public ValueDecl {
5550
+ friend class NeedsNewVTableEntryRequest ;
5551
+
5593
5552
public:
5594
5553
enum class BodyKind {
5595
5554
// / The function did not have a body in the source code file.
@@ -5659,6 +5618,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5659
5618
// / Location of the 'throws' token.
5660
5619
SourceLoc ThrowsLoc;
5661
5620
5621
+ struct {
5622
+ unsigned NeedsNewVTableEntryComputed : 1 ;
5623
+ unsigned NeedsNewVTableEntry : 1 ;
5624
+ } LazySemanticInfo = { };
5625
+
5662
5626
AbstractFunctionDecl (DeclKind Kind, DeclContext *Parent, DeclName Name,
5663
5627
SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,
5664
5628
bool HasImplicitSelfDecl,
@@ -5670,8 +5634,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5670
5634
Bits.AbstractFunctionDecl .HasImplicitSelfDecl = HasImplicitSelfDecl;
5671
5635
Bits.AbstractFunctionDecl .Overridden = false ;
5672
5636
Bits.AbstractFunctionDecl .Throws = Throws;
5673
- Bits.AbstractFunctionDecl .NeedsNewVTableEntry = false ;
5674
- Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry = false ;
5675
5637
Bits.AbstractFunctionDecl .Synthesized = false ;
5676
5638
Bits.AbstractFunctionDecl .HasSingleExpressionBody = false ;
5677
5639
}
@@ -5841,16 +5803,9 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5841
5803
return getBodyKind () == BodyKind::MemberwiseInitializer;
5842
5804
}
5843
5805
5844
- void setNeedsNewVTableEntry (bool value) {
5845
- Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry = true ;
5846
- Bits.AbstractFunctionDecl .NeedsNewVTableEntry = value;
5847
- }
5848
-
5849
- bool needsNewVTableEntry () const {
5850
- if (!Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry )
5851
- const_cast <AbstractFunctionDecl *>(this )->computeNeedsNewVTableEntry ();
5852
- return Bits.AbstractFunctionDecl .NeedsNewVTableEntry ;
5853
- }
5806
+ // / For a method of a class, checks whether it will require a new entry in the
5807
+ // / vtable.
5808
+ bool needsNewVTableEntry () const ;
5854
5809
5855
5810
bool isEffectiveLinkageMoreVisibleThan (ValueDecl *other) const {
5856
5811
return (std::min (getEffectiveAccess (), AccessLevel::Public) >
@@ -5992,14 +5947,13 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
5992
5947
class FuncDecl : public AbstractFunctionDecl {
5993
5948
friend class AbstractFunctionDecl ;
5994
5949
friend class SelfAccessKindRequest ;
5950
+ friend class IsStaticRequest ;
5995
5951
5996
5952
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
5997
5953
SourceLoc FuncLoc; // Location of the 'func' token.
5998
5954
5999
5955
TypeLoc FnRetType;
6000
5956
6001
- OpaqueTypeDecl *OpaqueReturn = nullptr ;
6002
-
6003
5957
protected:
6004
5958
FuncDecl (DeclKind Kind,
6005
5959
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -6015,14 +5969,14 @@ class FuncDecl : public AbstractFunctionDecl {
6015
5969
StaticLoc (StaticLoc), FuncLoc(FuncLoc) {
6016
5970
assert (!Name.getBaseName ().isSpecial ());
6017
5971
6018
- Bits.FuncDecl .IsStatic =
6019
- StaticLoc.isValid () || StaticSpelling != StaticSpellingKind::None;
6020
5972
Bits.FuncDecl .StaticSpelling = static_cast <unsigned >(StaticSpelling);
6021
5973
6022
5974
Bits.FuncDecl .ForcedStaticDispatch = false ;
6023
5975
Bits.FuncDecl .SelfAccess =
6024
5976
static_cast <unsigned >(SelfAccessKind::NonMutating);
6025
5977
Bits.FuncDecl .SelfAccessComputed = false ;
5978
+ Bits.FuncDecl .IsStaticComputed = false ;
5979
+ Bits.FuncDecl .IsStatic = false ;
6026
5980
}
6027
5981
6028
5982
private:
@@ -6042,6 +5996,13 @@ class FuncDecl : public AbstractFunctionDecl {
6042
5996
return None;
6043
5997
}
6044
5998
5999
+ Optional<bool > getCachedIsStatic () const {
6000
+ if (Bits.FuncDecl .IsStaticComputed )
6001
+ return Bits.FuncDecl .IsStatic ;
6002
+
6003
+ return None;
6004
+ }
6005
+
6045
6006
public:
6046
6007
// / Factory function only for use by deserialization.
6047
6008
static FuncDecl *createDeserialized (ASTContext &Context, SourceLoc StaticLoc,
@@ -6064,16 +6025,16 @@ class FuncDecl : public AbstractFunctionDecl {
6064
6025
6065
6026
Identifier getName () const { return getFullName ().getBaseIdentifier (); }
6066
6027
6067
- bool isStatic () const {
6068
- return Bits.FuncDecl .IsStatic ;
6069
- }
6028
+ bool isStatic () const ;
6029
+
6070
6030
// / \returns the way 'static'/'class' was spelled in the source.
6071
6031
StaticSpellingKind getStaticSpelling () const {
6072
6032
return static_cast <StaticSpellingKind>(Bits.FuncDecl .StaticSpelling );
6073
6033
}
6074
6034
// / \returns the way 'static'/'class' should be spelled for this declaration.
6075
6035
StaticSpellingKind getCorrectStaticSpelling () const ;
6076
6036
void setStatic (bool IsStatic = true ) {
6037
+ Bits.FuncDecl .IsStaticComputed = true ;
6077
6038
Bits.FuncDecl .IsStatic = IsStatic;
6078
6039
}
6079
6040
@@ -6145,15 +6106,7 @@ class FuncDecl : public AbstractFunctionDecl {
6145
6106
}
6146
6107
6147
6108
OperatorDecl *getOperatorDecl () const ;
6148
-
6149
- OpaqueTypeDecl *getOpaqueResultTypeDecl () const {
6150
- return OpaqueReturn;
6151
- }
6152
- void setOpaqueResultTypeDecl (OpaqueTypeDecl *decl) {
6153
- assert (!OpaqueReturn && " already has opaque type decl" );
6154
- OpaqueReturn = decl;
6155
- }
6156
-
6109
+
6157
6110
// / Returns true if the function is forced to be statically dispatched.
6158
6111
bool hasForcedStaticDispatch () const {
6159
6112
return Bits.FuncDecl .ForcedStaticDispatch ;
0 commit comments