I am writing a static analysis tool for CIL. Control flow analysis would be simplified if finally blocks could be interpreted as try-catch blocks with a rethrow inside the catch. In C#, I fail to see the difference between
try
{
// ...
}
finally
{
// finally code here
}
and
try
{
// ...
}
catch
{
// finally code here
throw;
}
or between
try
{
// ...
}
catch(Exception e)
{
// catch code here
}
finally
{
// finally code here
}
and
try
{
try
{
// ...
}
catch (Exception e)
{
// catch code here
}
}
catch
{
// finally code here
throw;
}
There are even a finally block and endfinally instructions in the CIL. There must be a difference, is there?