staticcheck: fix loop detection algorithm
staticcheck: fix loop detection algorithm

The previous algorithm only worked for a specific subset of inputs,
namely when the checked block was the loop header.

Instead, correctly implement (natural) loop detection by finding all
back-edges and determining all blocks that are part of the loop.

The current implementation has poor theoretical performance and no
caching. So far, that's not a problem, because only few places need to
check for loops. Once we use this routine more often, it should be
improved.

dominikh/go-tools,dominikh/go-tools,dominikh/go-tools,dominikh/go-tools