davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
197 stars 58 forks source link

cpychecker reports confusing control-flow with multiple "return" statements #98

Open davidmalcolm opened 7 years ago

davidmalcolm commented 7 years ago

gimplification collapses each "return" in a function so that they share one GIMPLE_RETURN e.g. {{{ if (COND1) return EXPR1; return EXPR2; }}}

to the equivalent of e.g.: {{{ if (COND1) { _retval_1 = EXPR1; goto combined_return; }

_retval_2 = EXPR2; goto combined_return;

combined_return: _retval_3 = PHI<_retval_1, _retval_2> return _retval_3; }}}

This leads to confusing control flow in reports from cpychecker where the location of the return statement appears at the end of the function, rather than where the user might reasonably expect to see it.

See e.g.: https://lists.fedorahosted.org/pipermail/gcc-python-plugin/2014-May/000375.html

Hopefully we can fix such things up so that the "return" is reported at the source location.