Follow up to D116200, specifically adding the lifetime case.
I'm not terribly happy with this patch, and hoping someone else has a better idea. The tricky case is when the call is writeonly. If it read, we could rely on the block scan done for the read case just below, but we end up having to duplicate a bunch of logic just to handle the writeonly case.
A couple of thoughts:
- Maybe we just shouldn't handle this case? e.g. allow readwrite calls to be sunk with lifetimes, but bailtout with a comment explaining why?
- Maybe comesBefore (and potentially numbering the source block) isn't that bad afterall?
- Maybe we introduce a ScanBlockSuffix flag, reuse the existing code, and accept the false negative of their being unrelated writes in the block suffix? (Given this only causes additional false negatives for writeonly, maybe that's okay?)
clang-format: please reformat the code