silvas added a comment. This is just a drive-by comment, but you might be able to get away with less boilerplate by just teaching llvm-extract to do this. I don't feels strongly about this suggestion so do whatever you find best. https://reviews.llvm.org/D26778