* return a random parent block (including itself) or the global block (if 0 is returned) */
| 337 | * return a random parent block (including itself) or the global block (if 0 is returned) |
| 338 | */ |
| 339 | Block* |
| 340 | Block::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 |
no test coverage detected