Adds an overload of MemoryBuffer::getFileOrSTDIN which takes a callback ( void(*)(void) ) which is called if Filename is "-" and stdin has not had a file or pipe redirected to it, and exiting with return code 1. This is useful for programs which wish to read from stdin, but where it doesn't make sense to read from a character device. These programs can pass a callback to getFileOrSTDIN to do something like print help message.
Notably, although cl::printHelpMessage has two optional booleans, it cannot be converted to void(void). It's pretty awkward considering having inline void PrintHelpMessage() { PrintHelpMessage(); } will upset the compiler, but it cannot convert to void(void). I'm not sure what the easiest way to work around this is. Perhaps getFileOrSTDIN should not call exit on its own but let the callback do it and a PrintHelpAndExit function could be added to CommandLine.h. cl::printHelpMessage is an obvious candidate for this use case.
This patch depends on D63858 and uses sys::fs::is_tty in it currently.
ie -> i.e.