Replace '-' in the error message with <stdin>. This is also consistent with another error message in the code.
I have a vague and probably unreasonable concern that changing from the beahviour for a filename "<stdin>" could cause somebody some confusion somewhere, since it's non-standard. I do agree with changing the error message though (we do similar things already in other tools, IIRC). What are others' thoughts?
FWIW on windows file names seems can't contain "<" or ">" characters. On ubuntu it seems to be OK.
But my non-very-strong-but-still-feeling here is that your concern is valid.
I do agree with changing the error message though (we do similar things already in other tools, IIRC).
Improving the error message sounds good to me too.
Instead of changing the option default to "<stdin>, may could you add:
if (InputFilename == "-") InputFilename = "<stdin>"; // Overwrite for improved diagnostic messages
Just after the the getFileOrSTDIN() call?
The initial change would never treat <stdin> as a file name, it would special case this on open and use the correct - value. We only try to open a file once, but use the filename in multiple places, hence this to me was the simplest way to achieve this.
I've updated the diff based on the review comments, which changes the name of the file after opening. I like this less as it changes the state, and in my opinion just as confusing, if not a bit more vulnerable... However I also recognise that the size of this file is small, it appears to be reasonably tested, and I am not likely to be making many more changes to this file in the immediate future, so I can tolerate this.
This looks fine to me, although having looked at what other tools do, it might be better to create a reportError type of function that takes an input filename as an argument and does the conversion from '-' if needed. See for example llvm-readobj.cpp reportWarning etc. I'm happy either way, as a quick glance suggests this may not be straightforward here.