[llvm] [IR] Implement successors as Use iterators (PR #186616)

via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 14 12:33:40 PDT 2026


================
@@ -240,7 +240,7 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
 
     // Label source of switch edges with the associated value.
     if (const SwitchInst *SI = dyn_cast<SwitchInst>(Node->getTerminator())) {
-      unsigned SuccNo = I.getSuccessorIndex();
+      unsigned SuccNo = std::distance(succ_begin(SI), I);
----------------
safocl wrote:

Why not use `auto` here instead of `unsigned`? Is it guaranteed that the difference value will be less than the maximum value of the `unsigned` type?

https://github.com/llvm/llvm-project/pull/186616


More information about the llvm-commits mailing list