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 #99

Closed davidmalcolm closed 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.

davidmalcolm commented 7 years ago

Imported from trac issue 58. Created by dmalcolm on 2014-05-21T10:41:19, last modified: 2014-05-21T17:05:04

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2014-05-21 17:05:04:

Should be fixed as of ef48966bc952d2af637e6a34e92846af2c2210bf