This is an alternative implementation for D47540.
In this patch, I moved the code which produces the location part of a diagnostic message into a distinct place. I hope that this makes the overall code clearer because it simplifies other parts of the codebase.
The patch is primarily intended to demonstrate the approach and collect the feedback, which way we are going to go. The code is far from being perfect and has to be polished if this approach will be chosen.
This would have been useful for me too when I added new error messages to our fork of LLD. I just ended up copy-pasting the string constants from other files in lld.
I like this since it will ensure consistent warning message formats everywhere.