diff --git a/llvm/test/tools/llvm-reduce/fail-file-open.test b/llvm/test/tools/llvm-reduce/fail-file-open.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-reduce/fail-file-open.test @@ -0,0 +1,5 @@ +# RUN: not llvm-reduce --test=echo %s.NotAFileInTestingDir 2>&1 | FileCheck %s + +This file will not be read. An invalid file path is fed to llvm-reduce. + +# CHECK: llvm-reduce: {{.*}}.NotAFileInTestingDir: error: Could not open input file: No such file or directory \ No newline at end of file diff --git a/llvm/tools/llvm-reduce/llvm-reduce.cpp b/llvm/tools/llvm-reduce/llvm-reduce.cpp --- a/llvm/tools/llvm-reduce/llvm-reduce.cpp +++ b/llvm/tools/llvm-reduce/llvm-reduce.cpp @@ -116,6 +116,10 @@ std::unique_ptr OriginalProgram = parseInputFile(InputFilename, Context); + if (!OriginalProgram) { + return 1; + } + // Initialize test environment TestRunner Tester(TestFilename, TestArguments); Tester.setProgram(std::move(OriginalProgram));