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