@@ -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 ;
@@ -3558,8 +3541,6 @@ class EnumDecl final : public NominalTypeDecl {
3558
3541
return SourceRange (EnumLoc, getBraces ().End );
3559
3542
}
3560
3543
3561
- EnumElementDecl *getElement (Identifier Name) const ;
3562
-
3563
3544
public:
3564
3545
// / A range for iterating the elements of an enum.
3565
3546
using ElementRange = DowncastFilterRange<EnumElementDecl, DeclRange>;
@@ -4530,8 +4511,6 @@ class AbstractStorageDecl : public ValueDecl {
4530
4511
Bits.AbstractStorageDecl .IsStatic = IsStatic;
4531
4512
}
4532
4513
4533
- OpaqueTypeDecl *OpaqueReturn = nullptr ;
4534
-
4535
4514
public:
4536
4515
4537
4516
// / Should this declaration be treated as if annotated with transparent
@@ -4789,14 +4768,6 @@ class AbstractStorageDecl : public ValueDecl {
4789
4768
4790
4769
bool hasAnyDynamicReplacementAccessors () const ;
4791
4770
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
4771
// Implement isa/cast/dyncast/etc.
4801
4772
static bool classof (const Decl *D) {
4802
4773
return D->getKind () >= DeclKind::First_AbstractStorageDecl &&
@@ -5574,6 +5545,8 @@ class ImportAsMemberStatus {
5574
5545
5575
5546
// / Base class for function-like declarations.
5576
5547
class AbstractFunctionDecl : public GenericContext , public ValueDecl {
5548
+ friend class NeedsNewVTableEntryRequest ;
5549
+
5577
5550
public:
5578
5551
enum class BodyKind {
5579
5552
// / The function did not have a body in the source code file.
@@ -5643,6 +5616,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5643
5616
// / Location of the 'throws' token.
5644
5617
SourceLoc ThrowsLoc;
5645
5618
5619
+ struct {
5620
+ unsigned NeedsNewVTableEntryComputed : 1 ;
5621
+ unsigned NeedsNewVTableEntry : 1 ;
5622
+ } LazySemanticInfo = { };
5623
+
5646
5624
AbstractFunctionDecl (DeclKind Kind, DeclContext *Parent, DeclName Name,
5647
5625
SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,
5648
5626
bool HasImplicitSelfDecl,
@@ -5654,8 +5632,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5654
5632
Bits.AbstractFunctionDecl .HasImplicitSelfDecl = HasImplicitSelfDecl;
5655
5633
Bits.AbstractFunctionDecl .Overridden = false ;
5656
5634
Bits.AbstractFunctionDecl .Throws = Throws;
5657
- Bits.AbstractFunctionDecl .NeedsNewVTableEntry = false ;
5658
- Bits.AbstractFunctionDecl .HasComputedNeedsNewVTableEntry = false ;
5659
5635
Bits.AbstractFunctionDecl .Synthesized = false ;
5660
5636
Bits.AbstractFunctionDecl .HasSingleExpressionBody = false ;
5661
5637
}
@@ -5825,16 +5801,9 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5825
5801
return getBodyKind () == BodyKind::MemberwiseInitializer;
5826
5802
}
5827
5803
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
- }
5804
+ // / For a method of a class, checks whether it will require a new entry in the
5805
+ // / vtable.
5806
+ bool needsNewVTableEntry () const ;
5838
5807
5839
5808
bool isEffectiveLinkageMoreVisibleThan (ValueDecl *other) const {
5840
5809
return (std::min (getEffectiveAccess (), AccessLevel::Public) >
@@ -5976,14 +5945,13 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
5976
5945
class FuncDecl : public AbstractFunctionDecl {
5977
5946
friend class AbstractFunctionDecl ;
5978
5947
friend class SelfAccessKindRequest ;
5948
+ friend class IsStaticRequest ;
5979
5949
5980
5950
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
5981
5951
SourceLoc FuncLoc; // Location of the 'func' token.
5982
5952
5983
5953
TypeLoc FnRetType;
5984
5954
5985
- OpaqueTypeDecl *OpaqueReturn = nullptr ;
5986
-
5987
5955
protected:
5988
5956
FuncDecl (DeclKind Kind,
5989
5957
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -5999,14 +5967,14 @@ class FuncDecl : public AbstractFunctionDecl {
5999
5967
StaticLoc (StaticLoc), FuncLoc(FuncLoc) {
6000
5968
assert (!Name.getBaseName ().isSpecial ());
6001
5969
6002
- Bits.FuncDecl .IsStatic =
6003
- StaticLoc.isValid () || StaticSpelling != StaticSpellingKind::None;
6004
5970
Bits.FuncDecl .StaticSpelling = static_cast <unsigned >(StaticSpelling);
6005
5971
6006
5972
Bits.FuncDecl .ForcedStaticDispatch = false ;
6007
5973
Bits.FuncDecl .SelfAccess =
6008
5974
static_cast <unsigned >(SelfAccessKind::NonMutating);
6009
5975
Bits.FuncDecl .SelfAccessComputed = false ;
5976
+ Bits.FuncDecl .IsStaticComputed = false ;
5977
+ Bits.FuncDecl .IsStatic = false ;
6010
5978
}
6011
5979
6012
5980
private:
@@ -6026,6 +5994,13 @@ class FuncDecl : public AbstractFunctionDecl {
6026
5994
return None;
6027
5995
}
6028
5996
5997
+ Optional<bool > getCachedIsStatic () const {
5998
+ if (Bits.FuncDecl .IsStaticComputed )
5999
+ return Bits.FuncDecl .IsStatic ;
6000
+
6001
+ return None;
6002
+ }
6003
+
6029
6004
public:
6030
6005
// / Factory function only for use by deserialization.
6031
6006
static FuncDecl *createDeserialized (ASTContext &Context, SourceLoc StaticLoc,
@@ -6048,16 +6023,16 @@ class FuncDecl : public AbstractFunctionDecl {
6048
6023
6049
6024
Identifier getName () const { return getFullName ().getBaseIdentifier (); }
6050
6025
6051
- bool isStatic () const {
6052
- return Bits.FuncDecl .IsStatic ;
6053
- }
6026
+ bool isStatic () const ;
6027
+
6054
6028
// / \returns the way 'static'/'class' was spelled in the source.
6055
6029
StaticSpellingKind getStaticSpelling () const {
6056
6030
return static_cast <StaticSpellingKind>(Bits.FuncDecl .StaticSpelling );
6057
6031
}
6058
6032
// / \returns the way 'static'/'class' should be spelled for this declaration.
6059
6033
StaticSpellingKind getCorrectStaticSpelling () const ;
6060
6034
void setStatic (bool IsStatic = true ) {
6035
+ Bits.FuncDecl .IsStaticComputed = true ;
6061
6036
Bits.FuncDecl .IsStatic = IsStatic;
6062
6037
}
6063
6038
@@ -6129,15 +6104,7 @@ class FuncDecl : public AbstractFunctionDecl {
6129
6104
}
6130
6105
6131
6106
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
-
6107
+
6141
6108
// / Returns true if the function is forced to be statically dispatched.
6142
6109
bool hasForcedStaticDispatch () const {
6143
6110
return Bits.FuncDecl .ForcedStaticDispatch ;
@@ -6386,13 +6353,7 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
6386
6353
ParameterList *Params,
6387
6354
SourceLoc EqualsLoc,
6388
6355
LiteralExpr *RawValueExpr,
6389
- DeclContext *DC)
6390
- : DeclContext(DeclContextKind::EnumElementDecl, DC),
6391
- ValueDecl (DeclKind::EnumElement, DC, Name, IdentifierLoc),
6392
- Params(Params),
6393
- EqualsLoc(EqualsLoc),
6394
- RawValueExpr(RawValueExpr)
6395
- {}
6356
+ DeclContext *DC);
6396
6357
6397
6358
Identifier getName () const { return getFullName ().getBaseIdentifier (); }
6398
6359
@@ -6408,6 +6369,7 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
6408
6369
6409
6370
Type getArgumentInterfaceType () const ;
6410
6371
6372
+ void setParameterList (ParameterList *params);
6411
6373
ParameterList *getParameterList () const { return Params; }
6412
6374
6413
6375
// / Retrieves a fully typechecked raw value expression associated
0 commit comments