From 92148557f742d66f10aa9c3ceb853e4384bcf1a6 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sun, 13 Sep 2015 04:09:40 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247518 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-mc/llvm-mc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 6ecdb2eaa6d..678ad360330 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -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> BufferPtr = MemoryBuffer::getFileOrSTDIN(InputFilename); if (std::error_code EC = BufferPtr.getError()) { -- 2.34.1