[llvm-mc] More meaningful error if input file doesn't exist.

Before we just printed on stderr the program name. Now at least we
print the name of the file that doesn't exist. There's probably room
for improvement of error handling in llvm-mc (and the tools in general),
but still this is a step forward.

llvm-svn: 247518
This commit is contained in:
Davide Italiano 2015-09-13 04:09:40 +00:00
parent 8b960d22ad
commit 669e5bf5c4
1 changed files with 5 additions and 0 deletions

View File

@ -395,6 +395,11 @@ int main(int argc, char **argv) {
// construct the Triple object.
Triple TheTriple(TripleName);
if (InputFilename != "-" && !sys::fs::exists(InputFilename)) {
errs() << ProgName << ": '" << InputFilename << "': "
<< "No such file\n";
return 1;
}
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
MemoryBuffer::getFileOrSTDIN(InputFilename);
if (std::error_code EC = BufferPtr.getError()) {