source_func = call.declaration->definition;
/* Populate referenced_names from the target function so we can rename
- variables from the inlined function that would conflict. */
+ variables from the inlined function that would conflict. Only consider
+ names which declared in blocks linearly related to the target block. */
pass = REFERENCED;
- target_func.visit(*this);
+ tgt_blk.visit(*this);
+ for(const Block *b=&tgt_blk; b; b=b->parent)
+ for(const auto &kvp: b->variables)
+ referenced_names.insert(kvp.first);
/* Inline and rename passes must be interleaved so used variable names are
known when inlining the return statement. */