core: add ForEachBasicBlock method for ControlFlowGraph