@@ -20,10 +20,8 @@ namespace llvm {
2020struct NoActiveBlocksOption {};
2121
2222struct ActiveBlocksOption {
23- protected:
2423 SmallSetVector<BasicBlock *, 4 > ActiveBlocks;
25-
26- public:
24+ SmallSetVector<BasicBlock *, 4 > &getActiveBlocks () { return ActiveBlocks; }
2725 ActiveBlocksOption () = default ;
2826};
2927
@@ -41,9 +39,11 @@ struct ActiveBlocksOption {
4139// / returned by operator*.
4240template <bool EarlyFailure = true >
4341class LockstepReverseIterator
44- : public std::conditional_t <EarlyFailure, NoActiveBlocksOption,
45- ActiveBlocksOption> {
42+ : private std::conditional_t <EarlyFailure, NoActiveBlocksOption,
43+ ActiveBlocksOption> {
4644private:
45+ using Base = std::conditional_t <EarlyFailure, NoActiveBlocksOption,
46+ ActiveBlocksOption>;
4747 ArrayRef<BasicBlock *> Blocks;
4848 SmallVector<Instruction *, 4 > Insts;
4949 bool Fail;
@@ -89,8 +89,7 @@ class LockstepReverseIterator
8989 // copying. And we cannot simply sort Blocks as they need to match the
9090 // corresponding Values.
9191 SmallSetVector<BasicBlock *, 4 > &getActiveBlocks () {
92- static_assert (!EarlyFailure, " Unknown method" );
93- return this ->ActiveBlocks ;
92+ return Base::getActiveBlocks ();
9493 }
9594
9695 void restrictToBlocks (SmallSetVector<BasicBlock *, 4 > &Blocks) {
@@ -105,9 +104,9 @@ class LockstepReverseIterator
105104 }
106105 }
107106
108- void operator --() {
107+ LockstepReverseIterator & operator --() {
109108 if (Fail)
110- return ;
109+ return * this ;
111110 SmallVector<Instruction *, 4 > NewInsts;
112111 for (Instruction *Inst : Insts) {
113112 Instruction *Prev = Inst->getPrevNonDebugInstruction ();
@@ -116,37 +115,38 @@ class LockstepReverseIterator
116115 this ->ActiveBlocks .remove (Inst->getParent ());
117116 } else {
118117 Fail = true ;
119- return ;
118+ return * this ;
120119 }
121120 } else {
122121 NewInsts.push_back (Prev);
123122 }
124123 }
125- if (NewInsts.empty ()) {
124+ if (NewInsts.empty ())
126125 Fail = true ;
127- return ;
128- }
129- Insts = NewInsts ;
126+ else
127+ Insts = NewInsts;
128+ return * this ;
130129 }
131130
132- void operator ++() {
131+ LockstepReverseIterator &operator ++() {
132+ static_assert (EarlyFailure, " Unknown method" );
133133 if (Fail)
134- return ;
134+ return * this ;
135135 SmallVector<Instruction *, 4 > NewInsts;
136136 for (Instruction *Inst : Insts) {
137137 Instruction *Next = Inst->getNextNonDebugInstruction ();
138138 // Already at end of block.
139139 if (!Next) {
140140 Fail = true ;
141- return ;
141+ return * this ;
142142 }
143143 NewInsts.push_back (Next);
144144 }
145- if (NewInsts.empty ()) {
145+ if (NewInsts.empty ())
146146 Fail = true ;
147- return ;
148- }
149- Insts = NewInsts ;
147+ else
148+ Insts = NewInsts;
149+ return * this ;
150150 }
151151};
152152
0 commit comments