I'm aware that this CL lacks tests (it's not trivial to test this but I do have a few ideas). I don't want to invest any more time in this until the general approach is approved. http://llvm-reviews.chandlerc.com/D1378