<div dir="ltr">Hi,<div><br></div><div>As part of an ongoing work to extend the GraphDiff (this models a CFG view), I came across the need to have a common interface for accessing successors/predecessors in various IR units, such that a type such as `typename NodeT::succ_iterator` could be used in templated code.</div><div>In particular, the need arose for BasicBlocks, MachineBasicBlocks, VPBlockBase and clang::CFGBlock.</div><div><br></div><div>The least invasive change seemed to be to use the interface already being used in MachineBasicBlock and clang::CFGBlock, and: </div><div>(1) update BasicBlock to use this instead of the "global" `succ_iterator` in IR/CFG.h</div>(2) add the same interfaces in VPBlockBase as simple wrappers over existing Successors/Predecessors vectors.<div><br></div><div>I've been working on a few patches to make this happen, but I'd like the community's thoughts on this before deep-diving into code reviews.</div><div><br></div><div>For some concrete view of what the changes look like, I uploaded two preliminary patches:</div><div>(1) part 1: <a href="https://reviews.llvm.org/D75881" style="text-decoration-line:none"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">D75881</span></a>: Introducing class specific iterators</div><div>(2) <a href="https://reviews.llvm.org/D75882" style="text-decoration-line:none"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">D75882</span></a></div><div>(1) part 2: pending: Cleaning up existing usages; example replacement: `succ_begin(BB)` with `BB->succ_begin()`.<br></div><div>(1) part3/4: pending: Add class specific iterators to `Instruction` and clean up existing usages just as for `BasicBlock`.</div><div><br></div><div>I split the above (1) just to clarify what interfaces are added versus the NFC cleanups that follow. But it could be done just as well in a single patch.</div><div><br></div><div>I welcome comments on this, and if there's something I missed explaining please let me know.</div><div><br></div><div>Thank you,</div><div>Alina</div><div><br></div><div><br></div><div><br></div><div><br></div></div>