@@ -213,6 +213,12 @@ bool conflicting(const OverloadSignature& sig1, const OverloadSignature& sig2,
213
213
214
214
// / Decl - Base class for all declarations in Swift.
215
215
class alignas (1 << DeclAlignInBits) Decl {
216
+ enum class ValidationState {
217
+ Unchecked,
218
+ Checking,
219
+ Checked,
220
+ };
221
+
216
222
protected:
217
223
union { uint64_t OpaqueBits;
218
224
@@ -235,12 +241,8 @@ class alignas(1 << DeclAlignInBits) Decl {
235
241
// / FIXME: This is ugly.
236
242
EarlyAttrValidation : 1 ,
237
243
238
- // / \brief Whether this declaration is currently being validated.
239
- BeingValidated : 1 ,
240
-
241
- // / \brief Whether we have started validating the declaration; this *isn't*
242
- // / reset after finishing it.
243
- ValidationStarted : 1 ,
244
+ // / \brief The validation state of this declaration.
245
+ ValidationState : 2 ,
244
246
245
247
// / \brief Whether this declaration was added to the surrounding
246
248
// / DeclContext of an active #if config clause.
@@ -609,8 +611,7 @@ class alignas(1 << DeclAlignInBits) Decl {
609
611
Bits.Decl .Implicit = false ;
610
612
Bits.Decl .FromClang = false ;
611
613
Bits.Decl .EarlyAttrValidation = false ;
612
- Bits.Decl .BeingValidated = false ;
613
- Bits.Decl .ValidationStarted = false ;
614
+ Bits.Decl .ValidationState = unsigned (ValidationState::Unchecked);
614
615
Bits.Decl .EscapedFromIfConfig = false ;
615
616
}
616
617
@@ -759,25 +760,32 @@ class alignas(1 << DeclAlignInBits) Decl {
759
760
// / Whether the declaration has a valid interface type and
760
761
// / generic signature.
761
762
bool isBeingValidated () const {
762
- return Bits.Decl .BeingValidated ;
763
+ return Bits.Decl .ValidationState == unsigned (ValidationState::Checking) ;
763
764
}
764
765
765
766
// / Toggle whether or not the declaration is being validated.
766
767
void setIsBeingValidated (bool ibv = true ) {
767
- assert (Bits.Decl .BeingValidated != ibv);
768
- Bits.Decl .BeingValidated = ibv;
769
768
if (ibv) {
770
- Bits.Decl .ValidationStarted = true ;
769
+ assert (Bits.Decl .ValidationState == unsigned (ValidationState::Unchecked));
770
+ Bits.Decl .ValidationState = unsigned (ValidationState::Checking);
771
+ } else {
772
+ assert (Bits.Decl .ValidationState == unsigned (ValidationState::Checking));
773
+ Bits.Decl .ValidationState = unsigned (ValidationState::Checked);
771
774
}
772
775
}
773
776
774
- bool hasValidationStarted () const { return Bits.Decl .ValidationStarted ; }
777
+ bool hasValidationStarted () const {
778
+ return Bits.Decl .ValidationState >= unsigned (ValidationState::Checking);
779
+ }
775
780
776
781
// / Manually indicate that validation has started for the declaration.
777
782
// /
778
783
// / This is implied by setIsBeingValidated(true) (i.e. starting validation)
779
784
// / and so rarely needs to be called directly.
780
- void setValidationStarted () { Bits.Decl .ValidationStarted = true ; }
785
+ void setValidationStarted () {
786
+ if (Bits.Decl .ValidationState != unsigned (ValidationState::Checking))
787
+ Bits.Decl .ValidationState = unsigned (ValidationState::Checked);
788
+ }
781
789
782
790
bool escapedFromIfConfig () const {
783
791
return Bits.Decl .EscapedFromIfConfig ;
0 commit comments