Wouldn't it make sense to use the same method as used in all the other compile plugins for this? That way we would at least have it working the same way for all input formats/compilers for now.

If the way it's done in the compilers in general isn't perfect wouldn't it be a better idea to create a new issue to discuss how to improve it?
Seeing how the same code is used in at least the 4 locations mentioned by al3xandru one option to enhance it might be to make a function out of it (DRY and all ;)).