From 2e438ca03b69ce199f9d567fc5e4ca028d1018c4 Mon Sep 17 00:00:00 2001
From: Chris Lattner
-Instruction* pinst = &*i; +Instruction *pinst = &*i;
-Instruction* pinst = i; +Instruction *pinst = i;
-Function* F = ...; +Function *F = ...; for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) if (Instruction *Inst = dyn_cast<Instruction>(*i)) { @@ -1694,10 +1695,10 @@ the particular Instruction):+ + + +-Instruction* pi = ...; +Instruction *pi = ...; for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) { - Value* v = *i; + Value *v = *i; // ... }@@ -1710,6 +1711,36 @@ for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i)+ ++ +Iterating over the predecessors and successors of a block is quite easy +with the routines defined in "llvm/Support/CFG.h". Just use code like +this to iterate over all predecessors of BB:
+ +++ ++#include "llvm/Support/CFG.h" +BasicBlock *BB = ...; + +for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + BasicBlock *Pred = *PI; + // ... +} ++Similarly, to iterate over successors use +succ_iterator/succ_begin/succ_end.
+ +Making simple changes -- 2.34.1