MCPcopy Create free account
hub / github.com/csmith-project/csmith / random_parent_block

Method random_parent_block

src/Block.cpp:339–354  ·  view source on GitHub ↗

* return a random parent block (including itself) or the global block (if 0 is returned) */

Source from the content-addressed store, hash-verified

337 * return a random parent block (including itself) or the global block (if 0 is returned)
338 */
339Block*
340Block::random_parent_block(void)
341{
342 vector<Block*> blks;
343 if (CGOptions::global_variables()) {
344 blks.push_back(NULL);
345 }
346 Block* tmp = this;
347 while (tmp) {
348 blks.push_back(tmp);
349 tmp = tmp->parent;
350 }
351 int index = rnd_upto(blks.size());
352 ERROR_GUARD(NULL);
353 return blks[index];
354}
355
356/*
357 * return true if there is no way out of this block other than function return

Callers 1

Calls 2

rnd_uptoFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected