@@ -591,7 +591,7 @@ typedef IteratorRange<DeclIterator> DeclRange;
591
591
592
592
// / The kind of an \c IterableDeclContext.
593
593
enum class IterableDeclContextKind : uint8_t {
594
- NominalTypeDecl,
594
+ NominalTypeDecl = 0 ,
595
595
ExtensionDecl,
596
596
};
597
597
@@ -601,24 +601,28 @@ enum class IterableDeclContextKind : uint8_t {
601
601
// / Note that an iterable declaration context must inherit from both
602
602
// / \c IterableDeclContext and \c DeclContext.
603
603
class IterableDeclContext {
604
+ enum LazyMembers : unsigned {
605
+ Present = 1 << 0 ,
606
+
607
+ // / Lazy member loading has a variety of feedback loops that need to
608
+ // / switch to pseudo-empty-member behaviour to avoid infinite recursion;
609
+ // / we use this flag to control them.
610
+ InProgress = 1 << 1 ,
611
+ };
612
+
604
613
// / The first declaration in this context along with a bit indicating whether
605
614
// / the members of this context will be lazily produced.
606
- mutable llvm::PointerIntPair<Decl *, 1 , bool > FirstDeclAndLazyMembers;
615
+ mutable llvm::PointerIntPair<Decl *, 2 , LazyMembers > FirstDeclAndLazyMembers;
607
616
608
617
// / The last declaration in this context, used for efficient insertion,
609
618
// / along with the kind of iterable declaration context.
610
- mutable llvm::PointerIntPair<Decl *, 2 , IterableDeclContextKind>
619
+ mutable llvm::PointerIntPair<Decl *, 1 , IterableDeclContextKind>
611
620
LastDeclAndKind;
612
621
613
622
// / The DeclID this IDC was deserialized from, if any. Used for named lazy
614
623
// / member loading, as a key when doing lookup in this IDC.
615
624
serialization::DeclID SerialID;
616
625
617
- // / Lazy member loading has a variety of feedback loops that need to
618
- // / switch to pseudo-empty-member behaviour to avoid infinite recursion;
619
- // / we use this flag to control them.
620
- bool lazyMemberLoadingInProgress = false ;
621
-
622
626
template <class A , class B , class C >
623
627
friend struct ::llvm::cast_convert_val;
624
628
@@ -650,15 +654,20 @@ class IterableDeclContext {
650
654
651
655
// / Check whether there are lazily-loaded members.
652
656
bool hasLazyMembers () const {
653
- return FirstDeclAndLazyMembers.getInt ();
657
+ return FirstDeclAndLazyMembers.getInt () & LazyMembers::Present ;
654
658
}
655
659
656
660
bool isLoadingLazyMembers () {
657
- return lazyMemberLoadingInProgress ;
661
+ return FirstDeclAndLazyMembers. getInt () & LazyMembers::InProgress ;
658
662
}
659
663
660
664
void setLoadingLazyMembers (bool inProgress) {
661
- lazyMemberLoadingInProgress = inProgress;
665
+ LazyMembers status = FirstDeclAndLazyMembers.getInt ();
666
+ if (inProgress)
667
+ status = LazyMembers (status | LazyMembers::InProgress);
668
+ else
669
+ status = LazyMembers (status & ~LazyMembers::InProgress);
670
+ FirstDeclAndLazyMembers.setInt (status);
662
671
}
663
672
664
673
// / Setup the loader for lazily-loaded members.
0 commit comments