@@ -3294,6 +3294,63 @@ gcc_jit_blocks_clone (int num_blocks,
32943294 reinterpret_cast <gcc::jit::recording::block **> (out_clones));
32953295}
32963296
3297+ /* Public entrypoint. See description in libgccjit.h.
3298+
3299+ After error-checking, the real work is done by the
3300+ gcc::jit::recording::block::get_successor_blocks method in
3301+ jit-recording.cc. */
3302+
3303+ int
3304+ gcc_jit_block_get_successor_count (gcc_jit_block *block)
3305+ {
3306+ RETURN_VAL_IF_FAIL (block, 0 , NULL , NULL , " NULL block" );
3307+ gcc::jit::recording::context *ctxt = block->get_context ();
3308+ JIT_LOG_FUNC (ctxt->get_logger ());
3309+
3310+ /* An unterminated block has no successors. */
3311+ if (!block->has_been_terminated ())
3312+ return 0 ;
3313+
3314+ vec <gcc::jit::recording::block *> successors
3315+ = block->get_successor_blocks ();
3316+ int num_successors = successors.length ();
3317+ successors.release ();
3318+ return num_successors;
3319+ }
3320+
3321+ /* Public entrypoint. See description in libgccjit.h.
3322+
3323+ After error-checking, the real work is done by the
3324+ gcc::jit::recording::block::get_successor_blocks method in
3325+ jit-recording.cc. */
3326+
3327+ gcc_jit_block *
3328+ gcc_jit_block_get_successor (gcc_jit_block *block, int index)
3329+ {
3330+ RETURN_NULL_IF_FAIL (block, NULL , NULL , " NULL block" );
3331+ gcc::jit::recording::context *ctxt = block->get_context ();
3332+ JIT_LOG_FUNC (ctxt->get_logger ());
3333+ RETURN_NULL_IF_FAIL_PRINTF1 (
3334+ block->has_been_terminated (), ctxt, NULL ,
3335+ " block %s has not been terminated, so it has no successors" ,
3336+ block->get_debug_string ());
3337+
3338+ vec <gcc::jit::recording::block *> successors
3339+ = block->get_successor_blocks ();
3340+ gcc::jit::recording::block *successor = NULL ;
3341+ bool valid_index = index >= 0 && index < (int ) successors.length ();
3342+ if (valid_index)
3343+ successor = successors[index];
3344+ int num_successors = successors.length ();
3345+ successors.release ();
3346+
3347+ RETURN_NULL_IF_FAIL_PRINTF3 (
3348+ valid_index, ctxt, NULL ,
3349+ " index %i is out of range for block %s, which has %i successors" ,
3350+ index, block->get_debug_string (), num_successors);
3351+
3352+ return static_cast <gcc_jit_block *> (successor);
3353+ }
32973354
32983355/* Public entrypoint. See description in libgccjit.h.
32993356
0 commit comments