To do this, in the general case, you will need a symbolic analysis of values ββacross all control paths and a Boolean symbolic simplification to determine if the condition is true. For instance:
void bar(...a) { ... x=2*a; if (...) x=17; foo(x) ... } void foo(int x) { if (x<a && !x>5) {
To know that a line of dead code is really dead, you need to find all the calls to foo and verify that each of them causes this condition. So you need a global call graph, for which you need a global analysis of function pointers, for which global and, therefore, local points are needed - analysis ...
I do not know any ready-made tools that do this.
One could build with some effort using a program conversion system. Our DMS Software Reengineering Toolkit contains all these machines for C. Although all this equipment is not yet available for C #, it is implemented in a largely agnostic way, so getting there for C # is a sweat, but it is not impractical.
source share